ARTICLE AD BOX
First time posting (probably of many), new to Python and struggling to get my head around it. I've been tasked by uni to manipulate a csv file in Python.
Set up a strip & split command to clean up the data, and it works (feedback appreciated obvs). Code below...
with open("GLB.Ts+dSST_cleaned.csv") as csv: header = next(csv) # Format data_line = [line.strip().split(",") for line in csv] print(data_line[0])BUT, when I add a record count above it, the print(dataline) comes back empty. Conversely, if the record count goes below it, the record count doesn't return anything.
# File Open with open("GLB.Ts+dSST_cleaned.csv") as csv: header = next(csv) # Record Count record_count = 0 for record in csv: record_count += 1 print(record_count) # Format data_line = [line.strip().split(",") for line in csv] print(data_line[0])I'm sure this is a basic thing I'm not understanding about the core processes, but completely stumped.
I'm trying not to use the csv module at the moment. We've not covered this in class and waiting on clarification if it can be used.
Specifically, I need a record count to output correctly and the formatting to be able to return record information, instead of outputing as and empty list.
Help appreciated!
