Windows 上的文件偏移量
有没有一种简单的方法,最好使用脚本语言或可以通过批处理文件调用的小工具来操作文本文件,标记偏移量,并将偏移量之后的所有内容放入新文件中?
我有一个文本文件添加到 nightly,我想标记文件末尾,然后添加新数据后,仅处理偏移量和末尾之间的数据。 我不能仅使用字符串或分隔符来执行此操作,因为它是 blob 数据。
编辑:文本文件是通过从计划任务运行 ms access 宏来创建的,该宏将数据导出为 csv 文件。 在考虑帕特里克的建议时,我想知道是否可以在文件名中添加通配符(例如日期),以始终拥有不同的文件。 然后,该文件将被 scp 到 Linux 服务器,并加载到 mysql 数据库中。
Is there an easy way, preferably with a scripting language or a small tool that could be called through a batch file, to operate on a text file, mark an offset, and put everything after the offset into a new file?
I have a text file added to nightly, and I would like to make it so that the end of the file is marked, then after new data is added, only data between the offset and the end is processed. I can not do this with just strings or delimiters as it is blob data.
edit: The text file is created by running a ms access macro from a scheduled tasks, which exports the data as a csv file. In considering Patricks suggestion, I would like to know if it would be possible to add a wildcard such as the date to the filename, to always have a different file. This file will then be scp'd to a linux server, where it will be loaded into a mysql database.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 python 很简单:
用法和 输出示例:
It is simple with python:
Usage & output example:
假设您当前已使用脚本从 Access 数据库导出数据:
new_data.txt
中的输出将为:Assuming you're currently exporting the data from the Access database with a script already:
The output in
new_data.txt
will be:我可以想到 tail、bash 以及来自类 Unix 系统的其他实用程序。 您可以通过最少安装 MSYS 在 Windows 上获得这些内容。 引用这些实用程序的文档和示例很容易找到。 bash 的东西比 Windows 批处理文件强大得多。 该脚本看起来像这样:
I could think of tail, bash and other utilities from Unix-like systems. You could get those on Windows by minimally installing MSYS. Documentation and examples referring to these utilities are quite easy to find. And bash stuff is way stronger than Windows batch files. The script would look something like this: