阅读CSV文件与数组的AppleScript [英] Read CSV file as Array with AppleScript

查看:773
本文介绍了阅读CSV文件与数组的AppleScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一个CSV读取文件作为一个二维数组,然后将其返回到CSV文件。
比方说,这是我的CSV文件。这是一个excel文件和|意味着相邻小区:

I would like to read in a CSV file in as a 2D array and then return it back to a CSV file. Let's say that this is my CSV file. It is an excel file and the | implies the adjacent cell:

family | type
Doctor | Pediatrics
Engineer | Chemical

据我所知,有对AppleScript的非数组,只列出了和记录。如果这将是更好地与一个XLSX文件要做到这一点,请让我知道。

From what I understand, there are no arrays on applescript, just lists and records. If it would be better to do this with a XLSX file, please let me know.

推荐答案

薛明的CSV到列表转换器是我见过的最好的...

Nigel's CSV-to-list converter is the best I have seen ...

http://macscripter.net/viewtopic.php?pid=125444#p125444

有关你的榜样,请使用以下设置:

For your example, use these settings:

set csvText to "family | type
Doctor | Pediatrics
Engineer | Chemical"
csvToList(csvText, {separator:"|"}, {trimming:true})

V2

set csvText to read "/Users/user1385816/Desktop/yourfile.csv"
csvToList(csvText, {}, {trimming:true})

这篇关于阅读CSV文件与数组的AppleScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆