操作系统:Windows
工具:Python
文件:https://drive.google.com/file/d/1vVhQMbnQd8qvhZ51_91_hazBc-_7pc_9/view?usp=sharing
我有一个 csv 文件,自由文本列双引号,逗号分隔,反斜杠用于转义。我猜,由于 CR/LF,当我使用 Pandas/Excel 读取此 csv 文件时,有些行超出了位置。
在 python 中,如何删除所有 cr/lf 以便我可以正确读取 csv 文件?我试过了,没有按预期工作。
export class ModalComponent implements AfterViewInit {
@ContentChild(UserComponent) userComponent: UserComponent;
@ViewChild('contentTarget') contentTarget: ElementRef;
@ViewChild('footerTarget') footerTarget: ElementRef;
ngAfterViewInit() {
const content = this.userComponent.content.nativeElement;
const footer = this.userComponent.footer.nativeElement;
this.contentTarget.nativeElement.appendChild(content);
this.footerTarget.nativeElement.appendChild(footer);
}
}
答案 0 :(得分:0)
您显然没有正确设置转义字符。我可以毫无问题地读取您的文件(pandas 1.2.4):
import pandas as pd
pd.read_csv("sampledata.csv", escapechar="\\").T
输出:
0 1
Id a0o7F00000B6E3GQAV a0o7F000007b31GQAQ
LastModifiedDate 2021-05-04 05:37:21.0000000 2020-03-13 23:23:54.0000000
Description Every student needs it. We have created our "product" which is essenti...
Age 30 25