Sorry, I'm a noob. I have a csv file like this
customerID , gender , ...
5575-GNVDE , Female , ...
9763-GRSKD , Male , ...
I want put "customerID" column in list
ex:
print(customerID)
like
[5575-GNVDE, 9763-GRSKD , ...]
I already write the code
csvFile = open("WA_Fn-UseC_-Telco-Customer-Churn.csv", "r")
reader = csv.reader(csvFile)
# create list
customerID = []
for item in reader:
# ignore first line
if reader.line_num == 1:
continue
customerID += item[0]
print(customerID)
csvFile.close()
it show like this
['5', '5', '7', '5', '-', 'G', 'N', 'V', 'D', 'E','9', '7', '6', '3', '-', 'G', 'R', 'S', 'K', 'D',...]
I already read:
- Create a csv file with python and put in nested list to it
- Read txt file and put in list with python
- How do I read and write CSV files with Python?
- Reading rows from a CSV file in Python
- Python import csv to list
- How do I read and write CSV files with Python?
Please help me. Thank you.