将 OSX 上的文本文件格式设置为制表符分隔的文本文件
我有一个如下所示的文件,它是从我用 applescript 编写的程序输出的。
AXTitle: Blah
AXSize: Width: 300
AXSize: Height: 44
AXPosition: X: 217
AXPosition: Y: 170
AXHelp: Blah
AXValue: Value, On
AXEnabled: true
AXFocused: false
AXRole: AXStaticText
AXRoleDescription: Blah
AXTopLevelUIElement: Blah
AXWindow: Blah
我需要输入一种与数据库兼容的格式。所以制表符分隔格式。这是我想要输出的格式。我不需要上面的所有数据,只是我选择的数据
123 456 0 1 2 3 4 5 text text
123 456 0 1 2 3 4 5 text text
,我正在考虑使用正则表达式来根据需要格式化文本。 我可以在 applescript 中执行此操作吗?如果不是,考虑到我在 OSX 上工作,我应该看哪些程序? sed、gawk、perl、python?我可以将这些程序插入我的 applescript 程序中还是必须单独运行?
I have a file that looks like the following, which is outputted from a program i wrote in applescript.
AXTitle: Blah
AXSize: Width: 300
AXSize: Height: 44
AXPosition: X: 217
AXPosition: Y: 170
AXHelp: Blah
AXValue: Value, On
AXEnabled: true
AXFocused: false
AXRole: AXStaticText
AXRoleDescription: Blah
AXTopLevelUIElement: Blah
AXWindow: Blah
I need to put into a format that will be compatible with a database. So a tab delimited format. This is the format i would like to output it in. I don't need all the data above just what i select
123 456 0 1 2 3 4 5 text text
123 456 0 1 2 3 4 5 text text
I am thinking regular expressions to format text as i need.
Can i do this in applescript? If not what programs should i look at considering i am woking on OSX? sed, gawk, perl, python? Can i insert these programs in my applescript program or will i have to run separately?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您获取所选项目时,只需添加选项卡即可。您还可以将项目放入列表中,在列表中可以使用文本项目分隔符转换为项目之间带有制表符的字符串。
When you are getting your selected items, just add the tabs as you go. You can also put the items into a list, where you can use text item delimiters to convert to a string with tabs between the items.
这是一个很好的教程:
http://www.grymoire.com/Unix/Sed.html
Here is a good tutorial:
http://www.grymoire.com/Unix/Sed.html