Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby库可以阅读苹果数字文档吗?_Ruby - Fatal编程技术网

Ruby库可以阅读苹果数字文档吗?

Ruby库可以阅读苹果数字文档吗?,ruby,Ruby,有几个Ruby开源库可用于读取Microsoft Excel文件,如或。苹果数字文档呢?有什么可用的吗?这样的库显然还不存在。现在一个好的解决方法是通过applescript自动转换为CSV,然后读取结果,而不是直接读取数字文件。不过,这可能不适合每个人的需要,但对我来说非常适合 以下是applescript: # ------------------------------------------------------------------------------- # Command-l

有几个Ruby开源库可用于读取Microsoft Excel文件,如或。苹果数字文档呢?有什么可用的吗?

这样的库显然还不存在。现在一个好的解决方法是通过applescript自动转换为CSV,然后读取结果,而不是直接读取数字文件。不过,这可能不适合每个人的需要,但对我来说非常适合

以下是applescript:

# -------------------------------------------------------------------------------
# Command-line tool to convert an iWork '09 Numbers
# document to CSV.
#
# Parameters:
# - input: Numbers input file
# - output: CSV output file
#
# Attik System, Philippe Lang
#
# Creation date: 31 mai 2012
# Modification date: 
# -------------------------------------------------------------------------------
on run argv
    # We retreive the path of the script
    set myPath to (path to me)
    tell application "Finder" to set myFolder to folder of myPath

    # We get the command line parameters
    set input_file to item 1 of argv
    set output_file to item 2 of argv

    # We retreive the extension of the file
    set theInfo to (info for (input_file))
    set extname to name extension of (theInfo)

    # Paths
    set input_file_path to (myFolder as text) & input_file
    set output_file_path to (myFolder as text) & output_file

    if extname is equal to "numbers" then
        tell application "Numbers"
            open input_file_path
            save document 1 as "LSDocumentTypeCSV" in output_file_path
            close every window saving no
        end tell
    end if
end run
像这样使用它:

osascript convert_to_csv.scpt input_file.numbers output_file.csv