读取csv文件时清除空白行 [英] Erase blank rows while reading csv file
本文介绍了读取csv文件时清除空白行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图从cvs文件中删除空白行,但这不起作用,它只会写出第一行
I have tried to delete blank rows from my cvs file, however this is not working, it only writes out the first line
请看一下,告诉我如何获取所有带有文本的行,并跳过空白行
please take a look and tell me how i can get all the rows with text and skip the rows that are blank
这是代码: 我只是读出了csv文件的第一行
Here is the code: I just reads out the first line of the csv file
先谢谢您!
推荐答案
首先使用pandas阅读您的csv文件
First read your csv file with pandas with
df=pd.read_csv('input.csv')
然后删除空白行,
df=df.dropna()
For more details in dropna, check the documentation.
这篇关于读取csv文件时清除空白行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文