Hi Team,
I am working on below python script which task is "It will take whatever data present in a .txt file and load it into in a .csv file as output.My code is working but the issue is everything is coming as rows in CSV output.
Below is my code:-
I have data in input .txt file:-
need your valuable suggestions.
Thak you
Chinmay Nayak
I am working on below python script which task is "It will take whatever data present in a .txt file and load it into in a .csv file as output.My code is working but the issue is everything is coming as rows in CSV output.
Below is my code:-
# - *- coding: utf- 8 - *- import os.path import csv save_path = "C:\Users\desktop\Python-testing\" completeName_in = os.path.join(save_path,'Input_file'+'.txt') completeName_out = os.path.join(save_path,'Output_file_csv'+'.csv') file1=open(completeName_in) In_text = csv.reader(file1,delimiter = ';') file2 =open(completeName_out,'w') out_csv = csv.writer(file2) file3 = out_csv.writerows(In_text) file1.close() file2.close()---------------------------------------------------------------------------
I have data in input .txt file:-
Output:Line no: 1
Line: This is Line1
Line no: 2
Line: This is Line2
Line no: 3
Line: This is Line3
----And I am getting below as output in .csv format:-Output:Line no: 1
Line: This is Line1
Line no: 2
Line: This is Line2
Line no: 3
Line: This is Line3
-----------whereas I need help in getting data like this:-Output:Line no: Line:
1 This is Line1
2 This is Line1
3 This is Line1
P.S:- I am unable to attach either csv output file or any screenshot.Please bear with me.need your valuable suggestions.
Thak you
Chinmay Nayak