I have a CSV file that has numerous data points included in each row, despite belonging to the same column. Something similar to this:
A, B, C, X, Y, Z Now, what I would like to do is to reformat the file such that the resulting CSV is:
A, B, C X, Y, Z I'm not too sure how to go about this / express it in a pythonic way. One idea (which I wasn't sure how to code) was to create a for loop similar to
For elements in file: new_csv = [] counter = 0 max_counter = 3 ##I'm using english because I dont know how to express it in python syntax take first element in CSV and add 1 to counter append first element to new_csv is counter < max_counter? if yes: go to next element if no: append /n to new csv then go to next element This probably is a terrible way to do it, but I'm struggling to find another way. How would I express this in the python syntax? Any ideas?