简体   繁体   中英

error reading csv file using panda python

import pandas
from bs4 import BeautifulSoup
import requests

df_list = []
path = "C:/Users/bubai/Desktop/try/scrapy/output"
for file in os.listdir(path):
   df_list.append(path + '/' + file)
#print(df_list) 

for i in df_list:  
    df = pandas.read_csv(i,delimiter=',',usecols = [1], low_memory = False, index_col=None, header=0) 
    f = open(fname,"w",encoding="utf-8")
    f.write(str(df))
    print(df)
    f.close()

this will print everything fine but the counting start from the second one, " चुनी हुई कविताएँ" will not assign any number it assign from "उत्तर प्रियदर्शी".

here is the output

0                                  उत्तर प्रियदर्शी
1                                   वसंत का अग्रदूत
2                                             संवाद
3                         ‘अज्ञेय’ : अपनी निगाह में
4                                   ऋण-स्वीकारी हूँ
5                        कला का स्वाभाव और उद्देश्य
6                        कविता : श्रव्य से पाठ्य तक
7                                   काल का डमरु-नाद

put header = None not 0. The first row is being read as header here because of this argument.

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