使用python分割每个nrows的excel表单
我有一个超过100万行的Excel文件。 现在我需要拆分每n行,并将其保存在一个新的文件。 对python来说是非常新的。 任何帮助,非常感激和需要
按照OhAuth的build议,您可以将Excel文档保存为csv
文件。 这将是开始处理你的数据的一个好的开始。
处理你的数据你可以使用Python的csv库 。 这不需要任何安装,因为它自动带有Python。
如果你想要更“强大”的东西,你可能想看看pandas 。 但是,这需要安装模块。
如果你不想使用Python的csv
模块,也不想使用pandas
模块,因为你不想读取文档,你也可以做类似的事情。
f = open("myCSVfile", "r") for row in f: singleRow = row.split(",") #replace the "," with the delimiter you chose to seperate your columns print singleRow > [value1, value2, value3, ...] #it returns a list and list comprehension is well documented and easy to understand, thus, further processing wont be difficult
不过,我强烈build议寻找模块,因为他们更好地处理csv
数据,更有效率和“远射”,节省您的时间和麻烦。