简体   繁体   中英

How to print dates from csv file in python without importing pandas

i have data in csv file data as follow 2021-03-26 2021-03-27 2021-04-03

I want the output as {2021-03-26,2021-03-27,2021-04-03}

you can read the file and its data and split it with space.

if your csv contains data on multiple lines then you can add for loop for each line and split each line you will get the list of dates.

check below code:

with open("csv file path", 'r') as fp:
    data = fp.read()
    
data = data.strip()
dates = data.split(' ')
print(dates)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM