All,
This is a snippet of a text file that I need to change into a csv file.
|head1|head2|head3|
+----+------+-----+
|10000|10001|10002|
So I've used this python code to make it into a CSV.
#open the input & output files.
inputfile = open('tr2796h_05.10.txt', 'rb')
csv_file = r"mycsv1.csv"
out_csvfile = open(csv_file, 'wb')
#read in the correct lines
my_text = inputfile.readlines()[63:-8]
#convert to csv using | as delimiter
in_txt = csv.reader(my_text, delimiter = '|')
#hook csv writer to output file
out_csv = csv.writer(out_csvfile)
#write the data
out_csv.writerows(in_txt)
#close up
inputfile.close()
out_csvfile.close()
The output is this:
,head1,head2,head3,
,+----+------+-----+,
,10000,10001,10002,
as expected.
Question is this - how do I delete that second row?