[英]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我在 csv 文件数据中有数据如下 2021-03-26 2021-03-27 2021-04-03
I want the output as {2021-03-26,2021-03-27,2021-04-03}我希望 output 为 {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.如果您的 csv 包含多行数据,那么您可以为每一行添加 for 循环并拆分每一行,您将获得日期列表。
check below code:检查以下代码:
with open("csv file path", 'r') as fp:
data = fp.read()
data = data.strip()
dates = data.split(' ')
print(dates)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.