简体   繁体   English

如何解决excel行列困难?

[英]How to solve excel row and column difficulty?

i have a problem with excel.我的excel有问题。 I downloaded a csv that has data not separated by comma or other and are not divided by row or single cell.我下载了一个 csv,它的数据没有用逗号或其他分隔符分隔,也没有按行或单个单元格划分。 Here is a screenshot.这是一个屏幕截图。 How can i divide this data in python or R to manage them separated one by one?我如何在 python 或 R 中划分这些数据以将它们一一分开管理?

在此处输入图片说明

Thanks in advance提前致谢

If the number of columns is the same on all lines, this should work:如果所有行的列数都相同,这应该有效:

import pandas as pd


df = pd.read_csv('my_full_filepath.csv', sep ='|')
print(df.info())

Otherwise, you can try, as a first approach,否则,您可以尝试,作为第一种方法,

df = pd.read_csv('my_full_filepath.csv', sep ='|', error_bad_lines = False)
print(df.info())

If there are data dropped, you might have to try opening your dataframe with an argument passing the maximal number of columns of your file.如果有数据丢失,您可能必须尝试使用​​传递文件最大列数的参数打开数据框。 This can be done, for example by :这可以完成,例如:

n = int('number of my columns')
df = pd.read_csv('my_full_file_path.csv', sep ='|', names = range(n)) 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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