简体   繁体   English

Excel-将多列分隔符的字符串合并为一个

[英]Excel - Combine string from multiple columns with delimiters into one

I have thousands of rows in the below format: 我有以下格式的数千行:

Image ID    Image Title       Image Caption

4867        Bedroom           Bedroom
4866|4865   Office|Kitchen    Office|Kitchen

I need to take related strings from these columns and combine them into a fourth column in this format: 我需要从这些列中获取相关的字符串,并将它们组合成这种格式的第四列:

Image ID    Image Title       Image Caption     Attachments

4867        Bedroom           Bedroom           {"image_attachments":[{"id":"4867","fields":{"title":"Bedroom","caption":"Bedroom"}}]}
4866|4865   Office|Kitchen    Office|Kitchen    {"image_attachments":[{"id":"4866","fields":{"title":"Office","caption":"Office"}}]},{"image_attachments":[{"id":"4865","fields":{"title":"Kitchen","caption":"Kitchen"}}]}

Can someone suggest the best way to accomplish this please? 有人可以建议实现此目的的最佳方法吗? Many thanks. 非常感谢。

You can use left/right/concatenate to accomplish this. 您可以使用left / right / concatenate完成此操作。 It'll be a bit time consuming to match your syntax exactly, but here's a sample. 完全匹配您的语法会花费一些时间,但这是一个示例。 Let me know if you get stuck. 让我知道您是否被卡住。 Notice that in order to include a double quote in a string in Excel, you use """ : 注意,为了在Excel的字符串中包含双引号,请使用"""

=CONCATENATE("""{image_attachments"":[{""",LEFT(A3,4))

Assuming that A3 is the cell containing the first Image ID, then the output is as follows: 假设A3是包含第一个图像ID的单元格,则输出如下:

"{image_attachments":[{"4867 “ {image_attachments”:[{“ 4867

After you finish this for the case where only one Image ID is in the cell, I'd wrap the entire thing in =IF(LEN(A3=4,DO THIS,IF(LEN(A3=9,DO THIS CODE),"") 在单元格中只有一个Image ID的情况下完成此操作之后,我将整个内容包装在=IF(LEN(A3=4,DO THIS,IF(LEN(A3=9,DO THIS CODE),"")

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

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