如何在一个单元格中取出一大段文本并插入回车符将其分成多个单元格?

发布于 2024-12-10 18:56:05 字数 313 浏览 0 评论 0原文

因此,我正在准备将数据插入到 sqlite 数据库中。从历史上看,我已将其放入 Excel 中,不同单元格中的数据相当于我的 db 表中的不同行(通过 csv 导入)。

现在,我从网页中提取了大量文本,该文本仅位于一个单元格中,但我需要将文本分解为不同的单元格。如何插入回车符?或者有没有一种方法可以将数据发送到 Excel 中,并使用一个符号自动将其放入单独的单元格中?或者我可以制作自己的自定义 csv 文件吗?除了剪切我想要移动的文本之外,还有更有效的方法吗?

文本中的一些数字是唯一的并且不断增加,我可以用它们来插入某些内容,但我不知道该怎么做。

请帮忙!

So I am working on prepping my data for insertion into a sqlite db. Historically, I have put it into excel, and the data in different cells has equated to different rows in my db table (through csv importation).

So now I have a huge bit of text that I have pulled from a webpage which is just in one cell, but I need to break the text up into different cells. How can I insert a carriage return? Or is there a way I can send the data into excel with a symbol that will automatically put it into separate cells? Or could I possibly make my own custom csv file? Aside from cutting the text I want to move, is there a more efficient way?

There are numbers that are in the text that are unique and increasing that I could use to insert something, but I can't figure out how to do it.

Please help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ヅ她的身影、若隐若现 2024-12-17 18:56:05

10 步解决方案...

  1. 选择带有巨大文本的单元格:
    step01
  2. 在任意位置插入分隔符(例如我选择“#”):
    step02
  3. 将硬回车替换为分隔符:
    step03
    您还可以选择使用公式来执行后者:
    =SUBSTITUTE(A1," <— 在此处插入 ALT+ENTER 以在引号之间进行硬回车
    ","#")
    这样您就不会意外地跳过任何硬返回(转换向导会卡住它们)。
  4. 启动所选单元格的文本到列转换向导:
    step04
  5. 选择分隔符:
    step05
  6. 选择分隔符:
    step06
  7. 复制生成的单元格范围以转置它们:
    step07
  8. 在起始单元格上选择“选择性粘贴”以粘贴转置范围:
    step08
  9. 选择转置...
    step09
  10. 完成!
    step10

A 10 step solution…

  1. Select the cell with the huge text:
    step01
  2. Insert your delimiter character (e.g. I chose '#') anywhere you wish:
    step02
  3. Replace hard returns by your delimiter character:
    step03
    You can also choose to do the latter with a formula:
    =SUBSTITUTE(A1," <— insert ALT+ENTER here for a hard return between the quotes
    ","#")
    This way you will not accidentally skip any hard returns (the conversion wizard chokes on them).
  4. Start the Text to Columns conversion wizard for the selected cell:
    step04
  5. Choose delimited:
    step05
  6. Choose delimiter:
    step06
  7. Copy the resulting range of cells in order to transpose them:
    step07
  8. Choose Paste Special on the starting cell for pasting the transposed range:
    step08
  9. Select Transpose…
    step09
  10. DONE!
    step10
榕城若虚 2024-12-17 18:56:05

您还可以操作 CSV 文件,而不是在 Excel 中工作。只需尊重 CSV 基础知识,您应该能够(进行一些实验,然后)完成工作:

CSV 文件以分隔数据格式保存逗号分隔值,其中字段/列由逗号字符分隔和由换行符终止的记录/行。
包含特殊字符(逗号、换行符或双引号)的字段必须用双引号括起来,然后将任何现有双引号加倍(以转义它们)。

因此,如果您看一下中的巨大单元格CSV 格式(只需使用任何纯文本编辑器),它可能跨越几行并用双引号括起来,就像这样?
之前
您可以将一个带引号的多行文本拆分为多个带引号的单行文本,如下所示:
之后

Instead of working in Excel, you can also manipulate the CSV file. Just respect the CSV basics and you should be able to (experiment a little and then) get the job done:

A CSV file holds Comma-Separated Values, in a delimited data format that has fields/columns separated by the comma character and records/rows terminated by newlines.
Fields that contain a special character (comma, newline, or double quote), must be enclosed in double quotes, after doubling any existing double quotes (to escape those).

So if you take a look a the huge cell in CSV format (just use any plain text editor), it probably spans several lines and is enclosed in double quotes, like this?
before
You can split up that one quoted multiline text into e.g. several quote single lines of text, such as shown below:
after

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文