I have directory A.
A contains a.txt, b.txt, c.txt.
I have directory B,
B contains a.csv, b.csv, c.csv.
I want am able to read and process files both separately as follows:
a.py
src = '/home/A'
file_paths = [os.path.join(src, f) for f in os.listdir(src)]
for file in file_paths:
for line in open(file, 'rb').readlines():
#do some some
# print some stuff
b.py
src = '/home/B'
file_paths = [os.path.join(src, f) for f in os.listdir(src)]
for file in file_paths:
with open(filename, 'r') as ff:
for line in ff:
_, end, label = line.strip().split('\t')
#do some some
# print some stuff
So results from a.py look like :
file_processed: a.txt
output
file processed: b.txt
output
file processed: c.txt
output
and similarly from b.py
file_processed: a.csv
output
file processed: b.csv
output
file processed: c.csv
output
I don't want to do this ^ process as it is hard to visually compare results of a.csv with a.txt because they are on two different terminals or files and so on.
What I want to do is :read files with same name from dir's at once and then perform computations and then print the results
Example: I should read a.txt from /A and process it , and then read a.csv from /B and process it. then print both results. Then move on to b.txt from /A and b.csv from /Band so on.
Please advise. Let me know if you want me to update the logic for do some stuff portion of the code.