Best way to store and retrieve data in a text file

I want to write to a text file and then in another Applescript read the same data into an array
I'll have 5 lines of text data
What would be the best format?
CSV?
XML maybe?
Just a plain file with each line of data separated by pressing enter?
Thanks
Omar

I agree with Frank - for just 5 lines, simple text is probably sufficient.
However, if the point is just to pass data between two AppleScripts you could even use native AppleScript objects - for example, you could write the list (array) to the file and then read it back in directly, e.g:
Write the data:
-- create a list of any types:
set myList to {"a string", 3.14159, "foo", {name:"Joe", age:21}}
-- create a file
set f to open for access (choose file name) with write permission
-- write your (binary) data to it
write myList to f
-- and close the file
close access f
Now, separately, you can read it back:
set x to read (choose file) as list

Similar Messages

  • What is the best way to load and convert data from a flat file?

    Hi,
    I want to load data from a flat file, convert dates, numbers and some fields with custom logic (e.g. 0,1 into N,Y) to the correct format.
    The rows where all to_number, to_date and custom conversions succeed should go into table STG_OK. If some conversion fails (due to an illegal format in the flat file), those rows (where the conversion raises some exception) should go into table STG_ERR.
    What is the best and easiest way to archive this?
    Thanks,
    Carsten.

    Hi,
    thanks for your answers so far!
    I gave them a thought and came up with two different alternatives:
    Alternative 1
    I load the data from the flat file into a staging table using sqlldr. I convert the data to the target format using sqlldr expressions.
    The columns of the staging table have the target format (date, number).
    The rows that cannot be loaded go into a bad file. I manually load the data from the bad file (without any conversion) into the error table.
    Alternative 2
    The columns of the staging table are all of type varchar2 regardless of the target format.
    I define data rules for all columns that require a later conversion.
    I load the data from the flat file into the staging table using external table or sqlldr without any data conversion.
    The rows that cannot be loaded go automatically into the error table.
    When I read the data from the staging table, I can safely convert it since it is already checked by the rules.
    What I dislike in alternative 1 is that I manually have to create a second file and a second mapping (ok, I can automate this using OMB*Plus).
    Further, I would prefer using expressions in the mapping for converting the data.
    What I dislike in alternative 2 is that I have to create a data rule and a conversion expression and then keep the data rule and the conversion expression in sync (in case of changes of the file format).
    I also would prefer to have the data in the staging table in the target format. Well, I might load it into a second staging table with columns having the target format. But that's another mapping and a lot of i/o.
    As far as I know I need the data quality option for using data rules, is that true?
    Is there another alternative without any of these drawbacks?
    Otherwise I think I will go for alternative 1.
    Thanks,
    Carsten.

  • What is the best way to store and search 2D data

    Hi,
    There is a set of data (~10k records ) in 2D dimension.
    like this :
    Col 1, Col 2, Col3....
    What is the best way to store and search those records ?
    Thanks in advance
    Wilson

    Hi,
    Either userObjet[][] if you know how much data you have, and the data size is fixed, or use a list of lists. E.g. A Vector of Vectors (some will probably say that you should use an ArrayList instead, and that could be the case, but it sounds like you would want to display the data later on, and a DefaultTableModel (for JTables) uses a Vector as data holder).
    Kaj

  • Can you suggest a best way to store and read arabic from oracle database?

    Hi ,
    can you suggest a best way to store and read arabic from oracle database?
    My oracle database is Oracle Database 10g Release 10.1.0.5.0 - 64bit Production on unix HP-UX ia64.
    NLS_NCHAR_CHARACTERSET AL16UTF16
    NLS_LANGUAGE AMERICAN
    NLS_TERRITORY AMERICA
    NLS_CHARACTERSET WE8ISO8859P1
    I have presently stored the data in nvarchar2 field. But i am not able to display it correctly.

    Using the national characterset should work but there are other factors that you have to consider when working with NCHAR/NVARCHAR2/NCLOB.
    If possible, changing the characterset is usually the best solution if it's a possiblity for you.
    For more info:
    Dear Gurus: Can u pls explain the difference between VARCHAR2 & NVARCHAR2??

  • Best way to store all this data!!

    Hi i have run into a problem and cant think at the mo. I need to know the best way to store this data:
    Meet(List of events in meet, Runners in meet, Relay team in meet, Which runner/ relay team is registered for which event, results of each event updated once meet is run, event being run(or has finished) or not started yet so runners can still register for it);
    Runner(RunnerID, Name, D.O.B, national team affiliation, Gender, Events in?, Seedtime for each event?, actual time for event?)
    RelayTeam(RelayID, Team name, Runner names, seedtime for events, events in, Acutal time)
    Event(ID, Name, Meet in, Runners in which lane)
    I just want to know how i can store these to make it as easy as possible to update etc.
    Anyhelp apprec.
    Thanks
    J

    Crossposted: http://forums.java.sun.com/thread.jsp?thread=509544&forum=31&message=2419334

  • Best way to store and access all my media over network?

    With nearly 500GBs of music, movies and TV in my iTunes library, my G5's hard drive is just about full. And since I tend to watch everything on my significantly faster Macbook Pro via Front Row, it means I have to keep my G5 up and running all the time. Which feels like a huge waste of energy.
    So... what's the most efficient way to store and access my media? Here are some ideas off the top of my head. If anyone has any better ideas, please share...
    IDEA 1: BUY A TERABYTE EXTERNAL DRIVE AND CONNECT TO MY AIRPORT EXTREME'S USB PORT.
    Pros...
    1.) No need to keep my G5 up and running all the time, just the router and the external drive connected to it.
    2.) All media stored in one iTunes library which can be accessed by any wireless Mac on my network.
    Cons...
    1.) I have no idea if this would even work.
    2.) Would the USB connection be fast enough to play HD content?
    3.) Would the Extreme's b/g signal be fast enough?
    4.) Would my Macs even recognize an iTunes Library on a USB hard drive connected to my Airport Extreme with no OS of its own?
    5.) Even if it were fast enough, could two separate Macs share the same iTunes library?
    6.) I'd have to lose my wireless printer, which currently occupies the single USB port in my Airport.
    IDEA 2: BUY AN APPLE TIME CAPSULE AND USE ITS INTERNAL DRIVE AS MY ITUNES LIBRARY
    Pros...
    1.) The internal SATA drive will certainly be faster than any external USB drive.
    2.) Get to keep my USB port for wireless printing.
    Cons...
    1.) Still don't know if it would work.
    2.) Would not be able to take advantage of faster 802.11(n) speed, as my G5 tower is b/g only.
    3.) Pricey. $500 for a Time Capsule seems excessive not being able to take advantage of n speed boost.
    IDEA 3: BUY AN APPLE TV
    Pros...
    1.) I could watch HD content on my beautiful 30 inch Apple Cinema Display!
    2.) I could access all my content wirelessly through my network.
    3.) I get to keep my wireless printer wireless.
    Cons...
    1.) I don't own a TV.
    2.) I don't know if Apple TV will even play on my 30 inch Apple Cinema Display.
    3.) I don't know if my Macbook Pro will play files from Apple TV.
    4.) Apple TV doesn't come with a Terabyte hard drive.
    5.) I'm not sure I really understand what Apple TV is. (With a 30 inch Cinema Display, doesn't buying a TV seem redundant?)
    IDEA 4: SELL MY G5, BUY A TIME CAPSULE, AND HOPE NO ONE EVER STEALS MY MACBOOK PRO.
    Pros...
    1.) Can take advantage of that speedy wireless (n) network.
    Cons...
    1.) Still don't know if a wireless iTunes library stored on a router would work.
    2.) What will I do with my 30 inch Apple cinema display?
    3.) No backup computer if something ever goes wrong.

    Perfectly possible:
    Make sure the drive is formatted Mac OS Extended (Journaled)
    1. Quit iPhoto
    2. Copy the iPhoto Library from your Pictures Folder to the External Disk.
    3. Hold down the option (or alt) key while launching iPhoto. From the resulting menu select 'Choose Library' and navigate to the new location. From that point on this will be the default location of your library.
    4. Test the library and when you're sure all is well, trash the one on your internal HD to free up space.
    Back up to the 2TB drie:
    Most Simple Back Up:
    Drag the iPhoto Library from your Pictures Folder to another Disk. This will make a copy on that disk.
    Slightly more complex: Use an app that will do incremental back ups. This is a very good way to work. The first time you run the back up the app will make a complete copy of the Library. Thereafter it will update the back up with the changes you have made. That makes subsequent back ups much faster. Many of these apps also have scheduling capabilities: So set it up and it will do the back up automatically.
    Example of such apps: Chronosync - but there are many others. Search on MacUpdate or the App Store
    Regards
    TD

  • Best way to store and back up data on Mac (retina)?

    Ok so I bought the 13 inch retina macbook pro (This is my very first mac btw, so I am still trying to get used to basic functions though it's getting there..) and I've researched it a bit but I have some issues on figuring out how I best should store my data.
    1. Is Time Machine not the best way to back up data? As it will delete the oldest data once the hardrive used is full?
    but on the other hand, backing things up manually will take a lot of pain and effort (Choosing the new files that haven't been transferred, accidentally copying a file you actually already put in your back up disk thus taking additional unnecessary space,etc) ...right?
    or is there a better way to do this?
    2. I want to have all media (music, photos, videos, anything except apps) on an external hard drive but I don't want to have to keep transferring it from iphotos or anything else to my external hard drive...
    Is there a way to do this a smarter way? It would be best if I could put everything directly to my harddrive instead of having to import thru iphotos (thus taking up space on my internal SSD first) THEN deleting it from iphotos :/
    As of now I am trying do configure this network storage system (called SeaGate GoFlex Home if anyone is interested) but I am wondering if this is really a reliable way to keep my stuff... I plan on putting music, photos and videos on there..along with word documents
    Is there a way to configure the mac to automatically download stuff to my external network drive instead of saving it on my SSD?
    Thanks in advance for any help /opinions

    kj8P wrote:
    Is Time Machine not the best way to back up data? As it will delete the oldest data once the hardrive used is full?
    Although Time Machine does delete oldest data when full, it doesn't back everything up every time - only the files that have changed since the last backup.  Storage is cheap these days so if you get a good sized drive (seems daft to get less than 1Tb and 2 or 3Tb cost not a great deal more), then unless you have a really large SSD on your MBP and fill it with stuff, it will be a long time before Time Machine starts deleting old stuff. Aim for a minimum of double your SSD capacity.
    This article gives a very detailed explanation of Time Machine and how it works - bear in mind that even when TM has to delete the oldest backups, it will not delete something that does not have a newer version.
    http://icanhelpyourmac.com/tip_archive/understanding_apples_time_machine/index.h tml

  • Whats is the easiest way to store and retrieve files using a DB?

    Hello,
    I have a web application where my users need to upload and retrieve files(.doc, .ppt. excel). I want to store them in the database instead of on the server. Anyone have any ideas on the easiest way to do this?
    Thanks,
    Danny

    Well, there's a BFILE data type-- that allows you to store essentially a pointer to a file in the database, though the file itself would be stored externally.
    A better option would be to store the data either as interMedia Text or as a B/CLOB, so all the data from the file would be stored in the file. interMedia Text gives a number of benefits if you're going to be working with the data-- i.e. searching the data, etc, but the additional work & restrictions may not be worth it if you just want to get the data in and out of the database whole.
    Justin

  • What is the best way to store and iterate over lists of words?

    Hi,
    Im trying to create a naive bayesian classifier to attribute aurthorship to some texts. I have three text files in the form of a list of words (listA, listB and listC, where listA is a disputed text and listB, listC are those of known authors). I need to feed these into my program, than compare listA to listB (to check if listA has the same words as listB), perform the classification and do the same for listA and listC.
    Im new to java and would like to know the best way of comparing the text files....could i store listA in an array....listB in a hashmap, iterate over the hashmap to check which words are also contained in listA and store the similar words in a seperate arraylist?
    plz help.

    If you just want to check if one set of words contains another set of words then something implementing java.util.Set might be sufficient. Read the API docs, you don't need to write much code yourself. Maps are for looking up values based on keys; your problem statement doesn't mention that so you don't need them. Lists are for when the order of entries matters. Read this for more information:
    http://java.sun.com/docs/books/tutorial/collections/index.html

  • What is the Best way To Copy and paste data from 1 book to another

     I have 18 sheets in 5 different books that I want to extract data from specific cells.  What is the best way to do this?  Example:  1 sheet is called Numbers E-O1 data in 13:WXYZ. The data updates and moves up 1 row every time I enter
    a new number. So let's say I enter the number 12. Through a lot of calculations the output goes in 13:WXYZ. To what I call a counter which is a 4 digit number.  Anyways, how can I send that 4 digit number to a totally different sheet?  To bullet
    what I'm talking about
    data in cells Row 13:WXYZ in book called Numbers sheet E-O1
    send data to book called "Vortex Numbers" Sheet E-O row 2001:CDEF
    What formula or Macro can I use to make this work?
    thank you!

    Hello Larbec,
    Syntax:
    '[BookName]SheetName'!Range
    Enter in cell  2001:CDEF:
    ='[Numbers]E-O1'!13:WXYZ
    This assumes that the file is open in Excel. Otherwise you need to add the path:
    'ThePath[BookName]SheetName'!Range
    Best regards George

  • Best way to export and import data from an iPhone app?

    How do people here prefer to export and import data from an iPhone app?
    For example, suppose your app creates or modifies a plist. It might be nice to provide that plist to the user for separate backup and later allow them to re-import it.
    How do people do that? Email the plist to an address? If so, how would one later get it back in?
    Is there a common way people do this kind of thing?
    Thanks,
    doug

    Or maybe the best approach for this is some sort of file synchronization feature? Is there a way of having files from the app's filesystem automatically get stored on the computer's filesystem when synchronizing and vice-versa?
    doug

  • Store and retrieve data from a FP-2000 using RT application

    Using labview RT build application can i store and retrive the data from Fp-2000. If so how much memory it will be free?
    Karthikeyan @ sivathasan
    Karaikudi - 630006
    India
    hp: +919442047691

    This question is a little like "If I put some water in a one gallon bucket, how much spae will be left?"
    It all depends on how much you put in.
    A clean efficient app will leave more space left over. Its been years since I wrota an app that did that on a FP-2000 but I seem te rember having enough memory left over to buffer a weeks worth of data provided the sample rate is kept low enough and updates are limited by dead-bands.
    I think that's all I can say to try and help for now.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Best way to control and read data from multiple instruments?

    Hello,
    I'm building an application to test power supplies involving multiple pieces of equipment over a couple of different comm busses. The application will also send control instructions to some of the instruments, and read data from some of the instruments. The reading and control profiles will not run on the same schedule (variable length control steps, configurable read interval).
    I was thinking of using a queued statemachine (producer/consumer) for the control profile and another to read the data, but I got concerned that there would be collisions between sending control commands and read commands to the same machine. Is there a suggested design pattern for implementing something like this?
    Timing of the commands isn't critical down to the milisecond, but I need to collect reasonably accurate timestamps when the data is read. The same is true for the control commands.
    Here are the instruments I'm going to use, if the are control, read, or both, and the communication method
    Instrument Funtions Comm Method
    Power Supply Read data Communicates to PMBus Adapter
    PMBus to USB Adapter Read data USB (Non-Visa)
    Switch control relays USB (VISA)
    Power Dist. Unit read data/control outlets SNMP (Ethernet)
    Electronic Load read data/control load GPIB (VISA)
    Thermal Chamber read data/control temp Ethernet (VISA)
    Thanks,
    Simon

    Hello, there is a template in LV called "Continuous measurement and Logging".
    It can give you some idea how to properly decouple the "GUI Event handler" top loop (where your Event structure is) from the DAQ and other loops.
    You do not need to totally replicate the above example, but you can find there nice tricks which can help you at certain points.
    The second loop from the top is the "UI message loop". It handles the commands coming from the top loop, and regarding to the local state machine and other possible conditions and states, it can command the other loops below.
    During normal run, the different instrument loops just do the data reading, but if you send a control command from the top loop to a certain instrument loop (use a separate Queue for every instrument loops), that loop will Dequeue the control command, execute it, and goes back to data reading mode (in data reading mode the loop Dequeu itself with a "data read" command automatically). In this way the control and data read modes happen in serial not in parallel which you want to avoid (but I think some instrument drivers can even handle parallel access, it will not happen in really parallel...).
    In every instrument loop when you read a value, attach a TimeStamp to it, and send this timestamp/value couple to the DataLogging loop via a Queue. You can use a cluster including 3 items: Source(instrument)/timestamp/value. All the instrument loops can use the same "Data logging" Queue. In the Datalogging while loop, after Dequeue-ing, you can Unbundle the cluster and save the timestamp and data-value into the required channel (different channel for every instrument) of a TDMS file.
    (Important: NEVER use 2 Event structures in the same top level "main" VI!)

  • Retrieve data from a text file and insert in table

    hi,
    i am writing an application which when executes would creates a user table and populates it with the data i.e. username and passwords taking it from a text file.
    i would like to know if anybody can help as to how can i retreive the user name and password for every insert statement that will be fired to populate the user table.
    thanks in advance for the help

    for csv try a little search:
    http://search.java.sun.com/Search/java?col=javafrm&qp=%2Bforum%3A31&qt=csv+import
    search for ini files:
    http://search.java.sun.com/Search/java?qt=ini+file&col=javafrm&rf=0&qp=%2Bforum%3A31
    hope this helps
    tobias

  • Retrieve data from a text file, incrementing the last value and save new value below

    Hi
    This was working initially. It is part of my LabView Project. I was trying to create a unique number that increments every time the adds the value to the list. It works on computer perfectly. But when I put this on a PDA, it seems to create a blank space when reading the contents of the text file after the last value, which means 0 + 1, which is not what I want.
    Please run the testUniqueNoOnPDA.vi first and change the path to C:\uniqueNumber.txt and save the uniqueNumber.txt file to your C drive and see What I am trying to do. Click the Enter button to increment.
    Why does the PDA create a blank space after the last value and a computer does not?
    I was working perfectly all week and it is not working well now.
    Help please, I think I'm missing something
    Attachments:
    uniqueNumber.txt ‏1 KB
    testUniqueNoOnPDA.vi ‏33 KB
    testUniqueNoOnPDA.lvproj ‏4 KB

    It works perfectly, it was a hardware problem. It depends on what PDA I used.

Maybe you are looking for