需要帮助根据另一个文本文件的内容从大型文本文件中删除条目
再会。在这件事上我真的需要你的帮助。我有一个以下格式的统计文本文件。
ID=1000000
Name=Name1
Field1=Value1
...(Fields 2 to 25)
Field26=Value26
ID=1000001
Name=Name2
Field1=Value1
...(Fields 2 to 25)
Field26=Value26
ID=1000002
Name=Name2
Field1=Value1
...(Fields 2 to 25)
Field26=Value26
...goes up to 15000
我有一个由换行符分隔的活动人员文本文件。
Name2
Name5
Name11
Name12
...goes up to 1400 Random Names
如果在活动人员文本文件中找不到该名称,我需要能够从统计文本文件(ID、名称、字段 1 到 26)中删除记录。在上面的示例中,Name1(ID、Name、Fields1 到 26)的关联记录应被删除,因为它不在活动人员文本文件中。
我尝试使用 TextFX->Quick->Find/Replace 通过记事本 ++ 重新格式化统计文件,将其转换为逗号分隔的文件,每个记录由换行符分隔。我将其重新排列为
ID Name Field1 ...Fields2 to Fields 25... Field26
1000000 Name1 Value1 ...Value2 to Value 25... Value26
1000001 Name2 Value1 ...Value2 to Value 25... Value26
1000002 Name2 Value1 ...Value2 to Value 25... Value26
用 Excel 打开它,并使用 csv 文件在 mysql 中创建了两个表(统计表和活动名称表)。我不确定如何在自动功能中处理这个问题。除了删除不活动的记录之外,我遇到的另一个问题是将其重写回旧格式。
我连续一个小时一直在尽力解决这个问题。有没有一种解决方案不需要我在两个文件之间使用查找、复制、粘贴和切换 1400 次?不幸的是,我必须以这种格式保存统计文件。
请帮忙。谢谢。
Good day. I could really use your help on this one. I have a stats text file in the following format.
ID=1000000
Name=Name1
Field1=Value1
...(Fields 2 to 25)
Field26=Value26
ID=1000001
Name=Name2
Field1=Value1
...(Fields 2 to 25)
Field26=Value26
ID=1000002
Name=Name2
Field1=Value1
...(Fields 2 to 25)
Field26=Value26
...goes up to 15000
I have an active people text file separated by line breaks.
Name2
Name5
Name11
Name12
...goes up to 1400 Random Names
I need to be able to delete records from the stats text file (ID, Name, Fields1 to 26) if the name is not found in the active people text file. In the example above, the associated record for Name1(ID, Name, Fields1 to 26) should be deleted since it's not in the active people text file.
I've tried reformatting the stats file through notepad++ using TextFX->Quick->Find/Replace to convert it to a comma separated file with each record separated by a line break. I had it rearranged to
ID Name Field1 ...Fields2 to Fields 25... Field26
1000000 Name1 Value1 ...Value2 to Value 25... Value26
1000001 Name2 Value1 ...Value2 to Value 25... Value26
1000002 Name2 Value1 ...Value2 to Value 25... Value26
I've opened it with excel and I've created two tables (stats table and a active names table) in mysql using the csv file file. I'm not sure how to process this in an automatic function. Besides removing inactive records, the other problem I have is rewriting it back to its old format.
I've been trying my best to figure this out for a hours on end. Is there a solution that won't require me to use find, copy, paste and switch between the two files 1400 times? Unfortunately, I have to keep the stats file in this format.
Please help. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个将为您处理文件的 C++ 程序:
Here's a C++ program that will process the files for you: