Nov-18-2020, 10:07 AM
Hello, I am new to Python,
I want to read a CSV file, but have some problems, hopefully, get some help,
I have a one-column data on CSV file since it is just one column data I am not sure if it does make any difference using a text file or CSV file,
anyhow I want to get each row of data from a range ( e.g. row 5 to row 14) one by one with some delay in between,
but with the code, I have there some problems.
I am grateful for your help to make this work.
Here is the output data:
I want to read a CSV file, but have some problems, hopefully, get some help,
I have a one-column data on CSV file since it is just one column data I am not sure if it does make any difference using a text file or CSV file,
anyhow I want to get each row of data from a range ( e.g. row 5 to row 14) one by one with some delay in between,
but with the code, I have there some problems.
- It prints out all rows (given range) at once, the timer does not work for the delay in between
- The output wrapps in '' and [],
import csv csvfile = open('my_file.csv','r') csvFileArray = [] for row in csv.reader(csvfile): csvFileArray.append(row) print(csvFileArray[5:11]) time.sleep(5)I want to insert this row of data in another function, but for the purpose of testing this code I use print function.
I am grateful for your help to make this work.
Here is the output data:
Output:[['164904789674679676'], ['771077704416674839'], ['844493667436017'], ['78777970164111066'], ['776316316771378360'], ['764687068316646778']]
and here is how the data is in CSV file:Output:644370674307387060
3769616199338017
10836877341311643
707147608047067661
164904789674679676
771077704416674839
844493667436017
78777970164111066
776316316771378360
764687068316646778
660179811186804894