Numbers to CSV export script: how to specify the encoding?

Hi,
I'm using the following script to export a Numbers document to CSV:
# 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
It works fine, except that I don't know how to specify the encoding of the text in the CSV file (Latin1, MacRoman, Unicode). This option is available in the export dialog of Numbers. Any hint on how to do that is welcome. (GUI Scripting?)
Where can I find documentation on the iWork "vocabulary" available? Is there a definitive documentation somewhere? I tried to record an manual export in the script editor, without success. Script is more or less empty.
Thanks!
Philippe Lang

A further note from Yvan. He's made some revisions to the script sent earlier.
--{code}
--[SCRIPT export to CSV with selected encoding]
I added some features.
(1) Defining the encoding thru the preferences file apply only if
the application is not in use because the file is read only once in a session.
A test urge you to quit Numbers if it is running.
(2) info for is deprecated so it may be removed by Apple tomorrow.
I no longer use it.
(3) just for the fun, I added a piece of code allowing you to select the encoding on the fly.
Thanks to the property chooseEncodingInScript, at this time the script use Unicode (UTF-8)
(4) I'm wondering which tool is used to launch this script,
I don't know the way to pass arguments when I run one.
Yvan KOENIG (VALLAURIS, France)
2012/06/13
property chooseEncodingInScript : false
true = the script will ask you to select the encoding
false = the script use the embedded encoding
on run argv
  set input_file to (item 1 of argv) as text
  set output_file to (item 2 of argv) as text
  set myPath to (path to me) as text
          tell application "System Events"
  set theProcesses to name of every application process
  set myFolder to path of container of (disk item myPath)
  set input_file_path to myFolder & input_file
  set output_file_path to myFolder & output_file
  set extname to name extension of (disk item input_file)
  end tell
          if extname is "numbers" then
                    if "Numbers" is in theProcesses then error "Please, quit “Numbers” before running this script !"
  if chooseEncodingInScript then
                              set theList to {"Mac OS Roman", "Unicode (UTF-8)", "Windows Latin 1"}
                              set maybe to choose from list theList with prompt "Choose the default encoding applying to export as CSV"
  if maybe is false then
  error number -128
  else if item 1 of maybe is item 1 of theList then
                                        30 -- Mac OS Roman
  else if item 1 of maybe is item 2 of theList then
                                        4 -- Unicode (UTF-8)
  else
                                        12 -- Windows Latin 1
  end if
  else
                              4 -- Unicode (UTF-8)
  end if
                    do shell script "defaults write com.apple.iWork.Numbers CSVExportEncoding  -int " & result
  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
--{code}
Regards,
Barry

Similar Messages

  • "Data only" csv export. How to get the same data?

    When I export to csv I get more data than when exporting to "data only". Why and how to get the same as when using "data only". I suppose it is because of some supressed lines, but why there is difference in the view (which is right) and in the export file?
    I do not want to export to xls with "data only" and save as csv, because the exported csv is being read by another application, which is unable to convert it automatically.
    The other way is to put constraints in the data selection for the whole report (and not by supressing lines). How to say {table.date}>=maximum({table.date}) in the  in the data selection? There is not possible to use "maximum". Probably possible with array?
    Thanks in advance
    Edited by: Kiril Bojilov on Aug 4, 2009 12:34 PM
    Ok, I managed it: I put the constraint in the group selection
    Edited by: Kiril Bojilov on Aug 4, 2009 12:46 PM

    New customers get more options because new customers didn't already agree to complete a 2yr contract before being able to get a new phone. If you had a line that wasn't under contract, you would get a better deal than new customers because while they pay $35 activation fee for a new line, you pay $30 upgrade fee for using an upgrade. You just have to finish your end of the deal before you can start a new one.

  • In sap scripts how to display the driver program

    Hi,
        I Want to know the sap scripts How to display the output to driver program

    Hi,
    Go to NACE Transaction.
    Select application for ex: if sales V1.
    Click on output types.
    Select the output type for ex : BA00
    Double click on Processing routines.
    There you can find the Driver Program name and Script/smart form name.
    Reward if useful.
    Thanks,
    Raju

  • How to specify page encoding for XML reports.

    Hi,
    Environment: Apps:11.5.10, Oracle Reports: 10g
    I'm trying to generate XML tags by using a "rdf" report (10g).
    Initially I generated the XML tags before moving the report to server. In the output file I got
    <?xml version="1.0" encoding="WINDOWS-1252"?>
    Then I moved the report to server and made the concurrent program output to XML.
    In the concurrent program output the tag is
    <?xml version="1.0" encoding="&Encoding"?>
    The output shows error
    ===============
    XML Parsing Error: XML declaration not well-formed
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    <?xml version="1.0" encoding="&Encoding"?>
    Its clear that there is something wrong with page encoding format which has to get assigned while run time. But its not happening so.
    How to specify the page encoding format?
    Any help would be appreciated.
    Thank you
    BKR.
    Edited by: BalaKrishna Reddy Avuthu on Aug 14, 2009 2:00 PM

    Remove the encoding so it says:
    <?xml version="1.0"?>
    Also, you will get a similar error if your xml tags for fields contain any special characters like & or #.

  • How to specify the target name while deploying a code in OSB-- Plz Help

    Hi all,
    Am working in creating a cluster environment. For my testing i created a new managed server(OSB_Server) in 9001 port in the admin console itself and that server started running. The default managed server(Admin_Server) is in 7001 port. So when i deploy a code in 7001 sb console the WSDL gets exposed in 7001 because the default admin server port is 7001. While deploying a code in service bus admin console we are not specifying the target name. So how to specify the target name while deploying the code in service bus admin console. Plz help me.
    Regards
    Prabhu

    Hi Prabhu,
    There are three kind of server architecture possible for OSB -
    1. Single server - Everything gets deployed on Admin server itself
    2. Admin Server + Single Managed Server for OSB -- OSB configuration gets deployed on OSB managed server. OSB resources (proxy service, WSDL, Schema) will remain available on OSB managed server port only and NOT on admin server port
    3. Admin Server + OSB cluster -- OSB configuration gets deployed on OSB cluster. OSB resources (proxy service, WSDL, Schema) will remain available on OSB Cluster port(s) only and NOT on admin server port
    Converting one type of server architecture to any other type, requires a manual tedious process, so it is suggested that you create domain accordingly i.e. if you need clusters then while creating domain itself, create OSB cluster, so that all OSB applications gets deployed to OSB cluster. I will suggest you to create a clustered domain from scratch and import the configuration from your existing domian to this new clustered domain.
    You may refer-
    http://download.oracle.com/docs/cd/E17904_01/doc.1111/e15022/toc.htm
    Regards,
    Anuj

  • How to specify the type of table in the form parameters

    How to specify the type of table in the form parameters. for example, how to specify the type of table "vacancies".
    FORM getcertainday
                       USING
                       vacancies TYPE STANDARD TABLE
                       efirstday LIKE hrp9200-zfirst_day
                       lfristday LIKE hrp9200-zfirst_day.

    Hi
    Are you asking about subroutine program to declare a variable for perform statement etc
    if it so check this coding
    DATA: NUM1 TYPE I,
    NUM2 TYPE I,
    SUM TYPE I.
    NUM1 = 2. NUM2 = 4.
    PERFORM ADDIT USING NUM1 NUM2 CHANGING SUM.
    NUM1 = 7. NUM2 = 11.
    PERFORM ADDIT USING NUM1 NUM2 CHANGING SUM.
    FORM ADDIT
           USING ADD_NUM1
                 ADD_NUM2
           CHANGING ADD_SUM.
      ADD_SUM = ADD_NUM1 + ADD_NUM2.
      PERFORM OUT USING ADD_NUM1 ADD_NUM2 ADD_SUM.
    ENDFORM.
    FORM OUT
           USING OUT_NUM1
                 OUT_NUM2
                 OUT_SUM.
      WRITE: / 'Sum of', OUT_NUM1, 'and', OUT_NUM2, 'is', OUT_SUM.
    ENDFORM.
    If your issue is some other can u explain me clearly
    Regards
    Pavan

  • How to specify the database file path when create FDM application

    Dear All,
    How to specify the database file path (MSSQL) when create FDM application?
    Right now, all data file are placed in the D:\ . I want to specify the database files (log and mdf file) in other place. How to do it?
    Thanks.

    Where is the highS2.xml located on the disk? If you add it to your project you should set its Build Action to Content and its Copy To Output Directory to Always in Visual Studio:
    Please remember to close your threads by marking helpful posts as answer once your issue has been solved and then start a new thread if you have a new question.

  • Reading text files without specifying the encoding?

    I have looked everywhere for a solution, but I can't find one. The problem is that I'm using codes that everybody is using, but for some reason, my codes aren't working.
    I want to be able to open up text files in Java without having to specify the encoding for the files that I'm going read, because I have no idea which encoding they will use.
    But even when specifying UTF-8 to be encoding of the file to read, it doesn't work correctly:
    FileInputStream fileIS= new FileInputStream("somefile.txt");
    Reader reader = new BufferedReader(new InputStreamReader(fileIS, Charset.forName("UTF-8")));
    EVERYWHERE I look, ppl are using these codes! But it doesn't work, some characters (such as the Euro sign) are displayed as squares.
    However, I want to be able to read not only UTF-8 files but anything that Java supports. Any ideas?
    Edited by: Stalfos on Oct 22, 2007 12:22 PM

    Stalfos wrote:
    I want to be able to open up text files in Java without having to specify the encoding for the files that I'm going read, because I have no idea which encoding they will use.
    This is your problem. If you don't know what encoding the text is stored in, then the chances that the default encoding used to read it will be correct are slim.
    But even when specifying UTF-8 to be encoding of the file to read, it doesn't work correctly:There are many different character encodings, and most of them don't overlap. Anything above 127 usually causes problems.
    FileInputStream fileIS= new FileInputStream("somefile.txt");
    Reader reader = new BufferedReader(new InputStreamReader(fileIS, Charset.forName("UTF-8")));
    EVERYWHERE I look, ppl are using these codes! But it doesn't work, some characters (such as the Euro sign) are displayed as squares.The problem isn't with the code, it's that the file you're reading isn't using an encoding that's compatible with UTF-8. Assuming that using UTF-8 should work for all encodings is like assuming that someone who can read Chinese should be able to read a book written in Spanish or Greek. It doesn't work that way.
    However, I want to be able to read not only UTF-8 files but anything that Java supports. Any ideas?You need to know what encoding your files are stored in, period. There are a few ways to guess what the encoding is, but they're only reliable for a small set of encodings.
    You don't seem to truly understand what character encodings are, or how to use them, so read this:
    The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)
    http://www.joelonsoftware.com/articles/Unicode.html

  • How to check the encoding of the String?

    hi everybody
    Could anyone tell how to tell from a String object in which encoding it is written? Is it UTF-8, UTF-16 etc. Is there any class that posses such a method. Another problem is that this solution must work under java 1.3.
    Thx in advance.

    Ok, but for example when you read from the file it
    can be encoded in the UTF-8 or ANSI coding. Yes, so you have to tell Java which encoding to use, or it will use your default encoding. Some of the I/O classes have constructors or methods that let you specify which encoding to use.
    Moreover
    when read from the request in a servlet it is usually
    encoded in the UTF-8 coding.If that's specified in the HTTP headers, then the core API classes that grab it before handing it to you will do the conversion I think.
    My question is how to
    determine the encoding. Maybe i wasn't clear enough
    in my previous post, sorry for that.In general, you can't just look at a file and know the encoding. You have to know, or have an external means to find out.

  • How to specify the AI version which file shall be compatible with?

    With AI 12.0.0 I need to save AI files so that they are compatible with AI version 10.
    Adobe help Center says:
    "Illustrator format options: When you save artwork to Illustrator format, you can set the following options: Version
    Specifies the version of Illustrator with which you want your file to be compatible."
    However, when I try to save the AI file I see no format options at all, so I cannot specify the desired AI version.
    How do I get access to the saving options?
    Arnold

    In AI 12 (CS2), you do not
    export, you
    save as. (The 'export' dalliance was instituted for v11 and abandoned for V12 as too confusing.)
    At the first save dialog (wherein you give your file a name), hitting 'Save' should get you to a second dialog. Choose the version you desire from the dropdown at top:

  • RMAN to disk script - how to get the hostname into the directory?

    I see you can get the Oracle SID in there but how to get the hostname?
    We have a NFS device where the directory is
    /backups/<hostname>/rman
    Ideas?
    This is not a unix script, ideally its run thru OEM.

    You never mentioned a version.
    Version is always important.
    From 9i and higher you don't need to allocate a channel, and you can CONFIGURE the default channels.
    You can also include a format specifier in the configuration command.
    This needs to be done only once.
    Apart from that: with that number of databases one would probably create a catalog and work with stored scripts, which can be called from a generic RMAN job.
    Stating 'it isn't possible' is too early, especially as you are scarce on information.
    Sybrand Bakker
    Senior Oracle DBA

  • How to specify the file path while doing bdc recording

    hi guys,
    using recording we specify transaction code where we enter all the details for the screen after that we get the recording program .....i have a doubt where can we specify the path for uploading a program from a local pc.......if possible can anyone provide a simple program to explain recording to upload an excel file from the system using recording

    Hi Gokul,
      You can use the following code to upload excel data into internal table.
       PARAMETERS: P_FILE LIKE RLGRAP-FILENAME.
        CALL FUNCTION 'WS_UPLOAD'
          EXPORTING
               CODEPAGE                = ' '
               FILENAME                = P_FILE
               FILETYPE                = 'DAT'
               HEADLEN                 = ' '
               LINE_EXIT               = ' '
               TRUNCLEN                = ' '
               USER_FORM               = ' '
               USER_PROG               = ' '
          IMPORTING
               FILELENGTH              =
           TABLES
                DATA_TAB                = IT_FILE
          EXCEPTIONS
               CONVERSION_ERROR        = 1
               FILE_OPEN_ERROR         = 2
               FILE_READ_ERROR         = 3
               INVALID_TABLE_WIDTH     = 4
               INVALID_TYPE            = 5
               NO_BATCH                = 6
               UNKNOWN_ERROR           = 7
               GUI_REFUSE_FILETRANSFER = 8
               CUSTOMER_ERROR          = 9
               OTHERS                  = 10
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ELSE.
        CLEAR IT_FILE.
      ENDIF.
    In SAP Enterprise edition, You can use FM : GUI_UPLOAD.
    From internal table, Data will be moved to BDCDATA and continue with BDC coding.
    Reward, if useful.
    Thanks,
    USR

  • SQL Server 2012 Management Studio: XML XQuery-query the XML Blob using CTE: How to specify the coorelation name in bulk rowset?

    Hi all,
    I just started doing the XML Xquery programming in my SQL Server 2012 Management Studio. I executed the following code:
    --query the XML Blob using a CTE (pulling from the XML file each time) Products
    WITH XmlFile (Contents) AS (
    SELECT CONVERT (XML, BulkColumn)
    FROM OPENROWSET (BULK 'H:\Products.xml', SINGLE_BLOB) ) AS XmlData
    SELECT *
    FROM XmlFile
    GO
    I got the the following Msg:
    Msg 491, Level 16, State 1, Line 4
    A correlation name must be specified for the bulk rowset in the from clause.
    How can I specify the correction name for the bulk rowset in my project?
    Please kindly help, advise and respond.
    Thanks in advance,
    Scott Chang

    Hello Scott,
    You have to assign a table alias for the OPENROWSET =>
    --query the XML Blob using a CTE (pulling from the XML file each time) Products
    WITH XmlFile (Contents) AS (
    SELECT CONVERT (XML, BulkColumn)
    FROM OPENROWSET (BULK 'H:\Products.xml', SINGLE_BLOB) AS MyXML ) AS XmlData
    SELECT *
    FROM XmlFile
    GO
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • How to specify the font in a JList?

    My application has four columns of data represented in a JList. The default font style does proportional spacing.
    I need to specify a fixed width font to control column alignment in the JList. Unless there's something like tab positions? If I can specify a fixed width font, I can format the display strings appropriately.
    I think I need to use a cell renderer to control the actual drawing of each cell in the JList?
    Also, where do I find a list of the font types?
    Thanks in advance!

    I don't think you need a cell renderer. You find out how to specify font names by (oddly enough) looking in the API documentation for the Font class; the info for the most usable-looking constructor tells you what you want to know.

  • Report Script - How to get the total on the any number of rows selected

    Hi,<BR>I am using Essase and report script for the reporting purpose. In this i would like to know how to get the sum of all the rows selected. I know we can use the calculate row, but it has to be done with print row to display the newly created row. But i am using alphablox where this print row is not working. Is there any other alternative is there to get the sum of any number of rows, and displaying them??<BR>Please help me.<BR><BR>Regards<BR>R.Prasanna

    Pls check the structure and index.
    EMP_ID NUMBER(9) NOT NULL,
    EMP_CD           NUMBER(3),
    EMP_NO VARCHAR2(250 BYTE) NOT NULL,
    FROM_EFF_DT DATE NOT NULL,
    TO_EFF_DT DATE,
    CREATE INDEX IDX_EMP_NO ON EMP
    (EMP_NO)
    NOLOGGING
    TABLESPACE INDEXES
    PCTFREE 20
    INITRANS 10
    MAXTRANS 255
    STORAGE (
    INITIAL 56K
    NEXT 1784K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    PCTINCREASE 0
    FREELISTS 4
    FREELIST GROUPS 1
    BUFFER_POOL DEFAULT
    NOPARALLEL;

Maybe you are looking for