[英]Can we parse .txt file and copy multiline parsed text to excel cell using python?
I am new to python.我是 python 的新手。 I have a data in.txt that repeats after start and end texts.
我有一个在开始和结束文本之后重复的数据 in.txt。 eg start line (always same character), some text lines below start line and finally end line.
例如起始行(总是相同的字符),起始行下方的一些文本行,最后是结束行。 This pattern continues.
这种模式仍在继续。 Every end line is followed by 2 hard enters, then new start line starts.
每条结束线后面跟着 2 个硬输入,然后新的开始线开始。 I believe it can be used as a delimiter.
我相信它可以用作分隔符。
I am looking to write something that can parse start to end lines (multi lines) and copy that to excel cell.我正在寻找可以解析开始到结束行(多行)并将其复制到 excel 单元格的东西。 So, excel cell will have all parsed multiline texts in 1 column.
因此,excel 单元格将在 1 列中包含所有已解析的多行文本。 For instance, cell A1 may have 5 line parsed text, A2 may have 7 line and so on depending on the parsed value from.txt files.
例如,单元格 A1 可能有 5 行解析文本,A2 可能有 7 行,依此类推,具体取决于来自 .txt 文件的解析值。
I have gone though many forums but still unsure how to do it.我去过很多论坛,但仍然不确定如何去做。 I will appreciate the help.
我将不胜感激。
@Sam K, I would suggest saving the.txt file as.csv file and adding double quote to indicate multiline row entry. @Sam K,我建议将 .txt 文件另存为 .csv 文件并添加双引号以指示多行行条目。
example of csv file content: csv 文件内容示例:
"TEST
1
2
3",
"TEST
4
5
6"
it will be rendered in excel as excel rendered rows它将在 excel 中呈现为excel 呈现的行
Hope this helps.希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.