Sep-05-2017, 08:20 AM
Modify the code, to get more detailed output of the occurring error.
Without a detailed error message, it's hard to find an error.
In your first example it looks like a ByteOrderMark for utf-8.
You can ship around this problem, if you open the file with the right encoding.
Otherwise it's guessing and guessing is not good in programming.
Without a detailed error message, it's hard to find an error.
import csv import os filename = os.path.abspath('/media/dfuu/Data/mt4/EU-1H.txt') def read_csv_data(filename): try: buffer = None with open(filename) as csvfile: buffer = csv.reader(csvfile, delimiter=',') for row in buffer: print(row) except csv.Error as e: print('Error reading {filename}') print(e) if __name__ == '__main__': read_csv_data(filename)Maybe you've still problem with parsing the text.
In your first example it looks like a ByteOrderMark for utf-8.
You can ship around this problem, if you open the file with the right encoding.
with open(filename, encoding='utf-8-sig') as csvfile:But before you do thins, look first which error you get.
Otherwise it's guessing and guessing is not good in programming.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!