Im using csv to write rows to an empty text file, but when I open the textfile I see there is a space between each letter/character. I have no idea what I'm doing wrong.
This is my code:
import csv import configparser # Read local `config.ini` file. config = configparser.ConfigParser() config.read(r'C:\data\FF\Desktop\Studio\cfg.ini') header_1= config['HEADERS']['headers_1'] header_2 =config['HEADERS']['headers_2'] full_path = r'C:\data\FF\Desktop\Studio\New Text Document.txt' with open(full_path, 'w') as output: writer = csv.writer(output, delimiter = '\t') writer.writerow(header_1) writer.writerow(header_2) This is how cfg.ini looks like:
[HEADERS] headers_2 = ['VEHICLE', 'MODEL', 'DSG', 'YEAR', 'MONTH', 'DAY', 'HOUR', 'MINUTE','SECOND'] headers_1 = ['*****data*****'] 
csv.writerow, but how you read the list fromcfg.ini. You read string, not list (as you think). And to fix the extra blank line - check stackoverflow.com/q/3348460/4046632json, thenheader_1 = json.loads(config['HEADERS']['headers_1']). That is assuming you don't change the current format incfg.ini, only replace'with"(double quotes, not 2 single-quotes)