I want to build a GUI to read and write csv files. Based on the output file I am creating another GUI for plotting. I am using pyQt4. There a 6 files in the folder. I want to read all the files having same name write in "out.csv" file. Then the other GUI will plot from "out.csv".
My code is:
def update(self):
cat1 = self.dropdown1.currentText()
counter = 1
for folder, sub_folders, files in os.walk(my_directory):
for special_file in files:
if cat1 == 'iono_tropo.csv':
file_path = os.path.join(folder, 'iono_tropo.csv')
elif cat1 == 'PR_log.csv':
file_path = os.path.join(folder, 'PR_log.csv')
elif cat1 == 'Satellite_info.csv':
file_path = os.path.join(folder, 'Satellite_info.csv')
elif cat1 == 'Sol_1.csv':
file_path = os.path.join(folder, 'Sol_1.csv')
elif cat1 == 'Sol_2.csv':
file_path = os.path.join(folder, 'Sol_2.csv')
else:
file_path = os.path.join(folder, 'Sol_3.csv')
with open(file_path) as read_file:
print('Reading csv file' + str(counter))
if counter == 1:
lines = read_file.readlines()
else:
lines += read_file.readlines()[1:]
with open ("out.csv","w") as f:
for line in lines:
f.write(line)
counter += 1
The script shows no error. But there is now "out.csv" file at destination. I am new in python program. When I run the code separately (not in GUI), it working. But here it shows nothing. Help please. Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire