Write data to a file wth time

Hi,
I am trying to record some data and time in a text file that I would be able to open the data file in Excel later. I have worked on the program and it works but I have some questions, and I would appreciate if somebody can help that I would be able to improve my code.
1) I wrote the data in a spreadsheet (test1 vi), however I read in the discussion forum that this not the best way to record the data since it slows down the program, and I am trying to run my code in a high sampling rate. So, I tried to write the data in a text file (test 2 vi), now the data is written 5 times for each time step (text file attach). Can somebody give me any suggestion what is wrong with the code that record the data more than one for each loop?
2) I am recording the time by using Tick count inside and outside the loop. Is there any better way to record the time?  
Thanks a lot,
Azadeh

Files are attached
Attachments:
test3.txt ‏275 KB
test1.vi ‏138 KB
test2.vi ‏146 KB

Similar Messages

  • HELP!!!!   How to read data from a file at time to time?

    i store temporary string data in a file(the data changes always), and i need to read the data in the file from time to time, so how can i read from the file like every 5 seconds?

    Please i need your help mr. noahw. i have a timer called timer1 inside that timer i am starting a thread to read the data in a file to me, then i have another timer timer 2 in which it takes the data already read from timer 1 and draws them on a GUI. the problem with me is that, i am unable to set a correct time for each of the two timers such that, every time timer one executes that is a new data is generated i need to draw only one figure coreesponding to those data, then when a new set of data is read i need to draw another figure based on the new data read, please help me with this becasue i need it urgently, this is my email, [email protected], and i can offer this reply as many points as you want if this helps you to help me, i am counting on you.

  • Write data to a file in OBPM 11g

    How to write data to a file in OBPM 11g?
    I want to capture all the data from the begin of an instance through the end. Please let me know how to do it.
    Thanks in advance..

    Hi Dharwat,
    Thanx for your answer. That class you mentioned needs an instream and an outstream. I have only an outstream.
    My program produces a normal ascii report data, but i must write into a file in UTF-16 format (that's what the customer want
    I know also class CL_ABAP_CONV_OUT_CE, but i don't know how to use it for an UTF-16 output.
    I hope someone can expain me very clearly how it works for an UTF-16 together with the open dataset statement.
    Thanx anyway.
    Gr., Frank
    Edited by: F. Bernsen on Nov 17, 2008 12:46 PM

  • How to write data to text file using external tables

    can anybody tell how to write data to text file using external tables concept?

    Hi,
    Using external table u can load the data in your local table in database,
    then using your local db table and UTL_FILE pacakge u can wrrite data to text file
    external table
    ~~~~~~~~~~~
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7002.htm#i2153251
    UTL_FILE
    ~~~~~~~~~
    http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_file.htm#sthref14093
    Message was edited by:
    Nicloei W
    Message was edited by:
    Nicloei W

  • How to Write data in Excel File using java

    Hi
    can anybody help me to write data in excel file
    using java code
    Thankx In Advance

    How much are you willing to pay for that?
    If you want it for free, http://jexcelapi.sourceforge.net/

  • How to write data to xml file?

    Hi,
    I have done a project which read data from a web then write in log file.
    Now i want to write data in xml file.
    how to write?
    i read some java and xml tutorial, quite quite difficult.
    Who can give a simple example with some comments?
    If you also give some tips on learning java web services, i will be very appreciated.
    Thanks
    Yang Bin

    Choose Xerces2.4 to serialize the DOM object is an option.
    javac XercesTest.java -classpath xmlParserAPIs.jar;xercesImpl.jar;.
    java -classpath xmlParserAPIs.jar;xercesImpl.jar;. XercesTest test.xml
    below is the source file: XercesTest.java
    //JAXP
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    //APACHE SERIALIZE FUNCTION
    import org.apache.xml.serialize.*;
    class XercesTest
    public static void main(String[] args) throws Exception
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse( new File( args[0] ) );
    File f = new File( "copy_of_"+ args[0] );
    OutputFormat format = new OutputFormat("xml","UTF-8",true ) ;
    FileOutputStream fout = new FileOutputStream( f );
    XMLSerializer ser = new XMLSerializer(fout, format );
    ser.serialize( doc );
    hope it's helpful
    land

  • Data Acquisition - using local variables to write data to a file

    Hello,
    I am running a Data Acquisition vi (currently in LabVIEW 7.1 but soon to be updated to 8.2) that collects ~100 parameters of data from several sources contained in a while loop. The current configuration (which I did not write) uses very few subVIs and writes to ~100 local variables to store each parameter. It then reads all the local variables and builds an array of all the strings, converts then to a spreadsheet string, then uses the write characters to file function to append to a datafile. I am trying to clean things up and have came up with subVIs to collect the data from the following sources:
    8 serial port sources collecting btwn 8 and 20 parameters each
    ~15 thermocouple readings
    ~10 analog inputs
    ~20 parameters read off an ARINC 429 bus.
    I have come up with a subVI to read each of the sources and have placed the subVIs in the while loop. Each subVI outputs the data that it collects in array or cluster form. I was wondering how best to write each parameter to a CSV file at between 1 and 10 Hz. Should I write each subVI output to a LV and then read them off as was done before (the difference being that I have reduced the # of LVs to ~10 vs >100?
    I should add that precise timing is not that important, so if all the subVIs are not collecting simultaneously (which I understand that they won't be), it does not really matter.
    Thanks.

    Hi jilla,
    jilla wrote:
    What I think that you are saying is to turn the outputs of the 4 subVIs into inputs of a 5th subVI that writes to the data file. Correct?
    Yes.  It may sound like a fine-point, but I beileve it's better to create a VI specifically for formatting data - in your example, 4 arrays IN, a single string OUT.  Then write the string to file as a seperate operation.  GUI-displayed data can go through a similar transformation, the four arrays wired to a subVI which builds output-structures specifically for display.  It's a beginner's mistake to put lots of individual controls and indicators on the screen when groups of them are naturally related (in an object-oriented sense.)  Use clusters to group related controls - this will keep the diagram much cleaner.
    One more question: at what point (either # of data points or frequency of data collection) does it become necessary to use queues? Thanks.
    Well, there's not really a clearly definable "point".  I'd say if your update-rate climbs above 100Hz, or you witness poor program or system performance, then it's time.  The scenario you've described is a fairly simple acquire/display&log loop - and simple is good.   Then-again people can't see/react-to updates faster than about 10Hz - so it doesn't make sense to sacrifice performance - if performance becomes an issue.
    Re: queues:  Queues are sometimes used to buffer data that's "produced" in one place and "consumed" in another.
    Here, if/when logging data, you're logging with every DAQ.  I wouldn't recommend using a queue to transport data from a "DAQ loop" to a "Logging-loop" - those functions can be in the same loop.  Should/could a queue be used to get data from a "DAQ loop" to update the GUI at a lower frequency?  Sure, but a Notifier might be a better choice.   Further, in the (simple?) program you've described, you might use a case structure (True/False) to only update FP indicators every "X" iterations - a simple solution that doesn't require Queues or Notifiers.
    Cheers!
    "Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)

  • Write data to .txt file with formatting

    Hi,
    I am trying to read data from serial port and write it on to a .txt file. I am able to write onto the file but it has got no formatting. What I would ideally like to do is, read the data from serial port, take only some parts of it and write on to the text file with proper formatting. Also, I would like to use the same file to append data each time. I am also having issues setting the pointer to EOF. I would like to append to end of file.
    This is my sample data
    18:33:23 02/10/10 28.32             0 LAC     0.378 mg/dL    0000\
    18:33:23 02/10/10 28.32             0 GLU       102 mg/dL    0000
    that is being read from the serial port. From this I would like to take only columns 1,2,3,5,6 and write onto the .txt file.
    Can someone provide some pointers? I'm using Labview 6.1
    Thanks,
    Sukanya

    If you know what "charecters" you don't want it is pretty easy. A little more difficult when they are unwanted only in certain places in the string. There is a remove whitespace function in the string functions palette. There is also a search and replace function in the "additional string functions" subpalette, that can be set up to find all instances of a char and replace it with something else, an empty string if you want to just delete it/them from your string.
    Putnam
    Certified LabVIEW Developer
    Senior Test Engineer
    Currently using LV 6.1-LabVIEW 2012, RT8.5
    LabVIEW Champion

  • Using textarea to write data to html files

    Hi. I am trying to make an application to change contents of html files. I used filereader and filewriter constructors but I guess I have a problem with using textarea. I want the data from the file to appear in a textarea so I can edit it and save.
    boolean saveFile () {
    JTextArea textarea = new JTextArea();
    JFrame frame = new JFrame();
    frame.add(textarea);
    File file = null;
    File fFile = new File ("default.java");
    JFileChooser fc = new JFileChooser ();
    htmlFilter fhtmlFilter = new htmlFilter();
    // Start in current directory
    fc.setCurrentDirectory (new File ("."));
    // Set filter for Java source files.
    fc.setFileFilter (fhtmlFilter);
    // Set to a default name for save.
    fc.setSelectedFile (fFile);
    // Open chooser dialog
    int result = fc.showSaveDialog (this);
    if (result == JFileChooser.CANCEL_OPTION) {
    return true;
    } else if (result == JFileChooser.APPROVE_OPTION) {
    fFile = fc.getSelectedFile ();
    return writeFile (file,textarea.getText);
    return true;
    // saveFile
    boolean openFile () {
    htmlFilter fhtmlFilter= new htmlFilter();
    File file = new File("");
    JTextArea textarea = new JTextArea();
    JFileChooser fc = new JFileChooser ();
    fc.setDialogTitle ("Open File");
    // Choose only files, not directories
    fc.setFileSelectionMode ( JFileChooser.FILES_ONLY);
    // Start in current directory
    fc.setCurrentDirectory (new File ("."));
    // Set filter for Java source files.
    fc.setFileFilter (fhtmlFilter);
    // Now open chooser
    int result = fc.showOpenDialog (this);
    if (result == JFileChooser.CANCEL_OPTION) {
    return true;
    } else if (result == JFileChooser.APPROVE_OPTION) {
    file = fc.getSelectedFile ();
    JFrame frame= new JFrame();
    frame.add(textarea);
    frame.pack();
    frame.setVisible(true);
    // Invoke the readFile method in this class
    return writeFile (file, textarea.getText ());
    return true;
    } // openFile
    public static boolean writeFile (File file, String dataString) {
    try {
    PrintWriter out =
    new PrintWriter (new BufferedWriter (new FileWriter (file)));
    out.print (dataString);
    out.flush ();
    out.close ();
    catch (IOException e) {
    return true;
    } // writeFile
    public String readFile(File file)
    JFrame frame= new JFrame();
    JTextArea textarea = new JTextArea();
    frame.add(textarea);
    StringBuffer contents = new StringBuffer();
    //declared here only to make visible to finally clause
    BufferedReader input = null;
    try {
    //use buffering, reading one line at a time
    //FileReader always assumes default encoding is OK!
    input = new BufferedReader( new FileReader(file) );
    String line; //not declared within while loop
    * readLine is a bit quirky :
    * it returns the content of a line MINUS the newline.
    * it returns null only for the END of the stream.
    * it returns an empty String if two newlines appear in a row.
    while (( line = input.readLine()) != null){
    System.out.println(line);
    catch (FileNotFoundException ex) {
    ex.printStackTrace();
    catch (IOException ex){
    ex.printStackTrace();
    finally {
    try {
    if (input!= null) {
    //flush and close both "input" and its underlying FileReader
    input.close();
    catch (IOException ex) {
    ex.printStackTrace();
    return contents.toString();
    }

    Sorry this didn't get a response sooner. You can alter the way your consumer loop writes the data to file by altering the data that you send through the queue. I would suggest clustering your data (the array you currently send) with an array of booleans. Then you can unbundle this cluster in the consumer loop before you write to file and use it accordingly. This should allow you to do what you're trying to do.
    Just to give you some feedback on your code, there are few things that you can improve upon. I'm sure this is a learning process so you probably know a lot more about LabVIEW now than you did when you started.
    All of your array operations in there can be done much simpler. You have a whole Index Array node that inputs 8-21 in order. This can be done by simply having an 8 at the beginning and dragging the rest down since the indices always count from the previous by default. You are also doing a lot of indexing and re-building of arrays. You should look int o Array Subset VI  and Array To Cluster node to consolidate here.
    You have a lot of indicators and controls that coudl be consolidated in to array and/or clusters. Your "element 1", "element 2", etc  indicators are all displayed on the front panel next to each other, so why not just display them as an array?
    You use property nodes in a couple places to read the values. This can be better done by a local variable. Property nodes shouldn't usually be read from continuously.

  • Write data  in  a file ?

    Hi ,
    I have a question regarding writing data in a text file. I have a lot of classes which are having lot of println statements. Can we send data to a file which are coming from different classes. I need to update file in sequencial way which are coming from different classes. I tried it . but it doesn't stored. can anyone rectify me.
    here is sample code ;
    in main method
       try {
      BufferedReader inFile = new BufferedReader(new FileReader(fileName));
      PrintWriter out = new PrintWriter(new FileWriter("OutFile.txt"));
    // calling  classA methods
    // calling classB methods
       out.close();           
       inFile.close();
       catch (IOException e) {
             System.exit(1);
    classA
      public void  method1()
      out.println(" message from classA - method1 ");
    public method2()
      out.println(" message from classA - method2");
    classB
      public void  method1()
      out.println(" message from classB - method1 ");
    public method2()
      out.println(" message from classB - method2");
    }  I need to call different methods in different times and update in a text file. can we do it ? Can anyone give suggestions for me.
    Thanks in advance,
    -balaji

    boss u r doing it a wrong way
    try this way
    create a method
    for writing file and pass a string parameter like this
    public void createLog(String data)
    try
    FilwWriter f=new FileWriter(new File("output.txt"))
    f.write(data)
    f.close();
    catch(Exception e)
    and whichevr class u want to enter data in text file just call this method
    createLog(" message from classA - method2");
    createLog(" message from classA - method1")
    createLog(" message from classB - method3")

  • Write Data to a file/Multiple Analogue Inputs

    Hi
    I want to write the x,y data of a spectrum graph to a file in the C drive as x vs y( as frequency data column and the respective amplitude data column). The following programme only write the y axis data. Also I need to record y axis data which exceed a certain threshold rather than all the y axis data. For example greater than 5. The ascii file can be opened by any text editor.Any idea on how to tackle this. (The main vi is in this page. The next message page will give the sub vi. Open both)
    Mal
    Attachments:
    spectr[1]mod2.vi ‏215 KB

    Try this. I took your two values from the top and bottom and created arrays for each using autoindexing terminals. After I created both arrays I built them into a 2d array. Using the previous example I turned them into a tab delimited string and then simply by using the write chars to file vi you will have your output files. I think this is what you are asking for. I moved the file I/O outside the loop so you are not wasting cpu by opening and closing the file every time the loop iterates. Hope this helps.
    BJD1613
    Lead Test Tools Development Engineer
    Philips Respironics
    Certified LV Architect / Instructor
    Attachments:
    AppMod.vi ‏227 KB

  • How to write data into a file

    Hi
    I want to write data from a string into a file. I am created a directory and a .doc file . But when i write this data from a string into .doc file , its give an error : File not found exception
    But, when i check in my directory, a file is created with blank.
    My code is:
    import java.io.*;
    import java.util.*;
    import java.lang.*;
    class createFile {
         public static void main(String[] args) {
    try {
         String mss = "This is for dedo";
         FileInputStream fis;
         FileOutputStream fos;
    File file = new File("C:\\JD\\m4.rtf");
    // Create file if it does not exist
    boolean success = file.createNewFile();
         success = true;
    if (success) {
                   System.out.println("suc");     
                   fis = new FileInputStream(mss);
                   System.out.println(fis);
              fos = new FileOutputStream(file);
              int c;
                   while ((c = fis.read()) != -1) {
         fos.write(c);
                   System.out.println("mss");
              fis.close();
              fos.close();
         System.out.println("created");
    // File did not exist and was created
    } else {
    // File already exists
    } catch (IOException e) {
         System.out.println(e);
    regards
    madhu

    InputStream inputStream = new ByteArrayInputStream(mss.getBytes());Use this to push into the file>
    Ummm.... no. InputStreams are for reading, not for writing.
    Anyway, OP, you're making a mistake. You're trying to open a stream to a file called "This is for dedo". Use FileOutputStream(File file) constructor or FileOutputStream(String pathToFile). You can then wrap that stream with a PrintWriter or whatever you need.

  • How to read and write data from json file from windows phone7 app

    Hi
    I am developing wp7 app for the use of students my questions are
    How can i write a code to read and write the json/text file for the wp7.
    I am using windows 7 OS, VS 2010 Edition.
    This is my code below:
    xaml:
    <Grid>
                        <TextBlock Height="45" HorizontalAlignment="Left" Margin="7,18,0,550" Name="textBlock1" Text="Full
    Name: " />
                        <TextBox Width="350" Height="70" HorizontalAlignment="Left" Margin="108,1,0,0" Name="txtName"
    Text="Enter your full name" VerticalAlignment="Top" />
                        <TextBlock Height="45" HorizontalAlignment="Left" Margin="6,75,0,0" Name="textBlock2" Text="Contact
    No: " VerticalAlignment="Top" />
                        <TextBox Width="350" Height="70" HorizontalAlignment="Left" Margin="108,61,0,480" Name="txtContact"
    Text="Enter your contact number" MaxLength="10" />
                        <Button Content="Register" Height="72" HorizontalAlignment="Left" Margin="10,330,0,0" Name="btnRegister"
    VerticalAlignment="Top" Width="190" Click="btnRegister_Click" />
                    </Grid>
    xaml.cs:
    private void btnRegister_Click(object sender, RoutedEventArgs e)
                string name, contact;
                name = txtName.Text;
                contact = txtContact.Text;
                try
                    if (name != "" && contact != "")
                        string msg = name + " " + contact;
                        MessageBox.Show(msg);
                        Student stud = new Student
                            Name= name,
                            Contact = contact,
                        string jsonString = JsonConvert.SerializeObject(stud);
                        MessageBox.Show(jsonString);
                    else
                        MessageBox.Show("Input Proper Information", MessageBoxButton.OK);
                catch (Exception ex)
                    MessageBox.Show(ex.Message);
    I have download NewtonSoft.json version 5.0.8.
    So, I am able to convert input data into json format, but how can I able to write and read this data from a json/text file.
    How can I do?
    Thank you in adv and please, reply soon.

    We don't have many samples left for Windows Phone 7 + Azure, the closest one to what you want to do is probably:
    Using Local Storage with OData on Windows Phone To Reduce Network Bandwidth
    this sample uses the local database feature: 'LINQ to SQL', available to Windows Phone 7.1 and 8.0 Silverlight applications, instead of simple file storage but even if you choose to stick with simple file storage I believe you should be able to adapt the
    networking related portions of the sample to your particular application.
    Eric Fleck, Windows Store and Windows Phone Developer Support. If you would like to provide feedback or suggestions for future improvements to the Windows Phone SDK please go to http://wpdev.uservoice.com/ where you can post your suggestions and/or cast
    your votes for existing suggestions.

  • Write data to Text file - Column by Column

    Hi,
    I want to write a table of data(2D) to a text file. I acquire 1D array(6 lakh rows) of data & want to write that in text file as column 0. And next 1D array to the same text file as column 2. Is it possible todo that?
    I don't want to accumulate 2D array and write at last since it consumes more memory & Labview Hangs.
    Kindly share your ideas.....
    Labview 8.2 
    Regards,
    Raja 

    HI,
               I hope this works for you but this vi doesnt hanged my PC or Labview. Please check with it and let me know.
    Regards,
    Gita
    Message Edited by AutoTEC on 10-17-2008 04:15 AM
    Attachments:
    Write column by column.vi ‏1398 KB

  • Unable to write data into excel file when it's close

    Hi,
    I'm facing this problem and it's a bit weird. I'm using the following method to insert data into excel file. But when excel file is close, it unable to write data into the excel sheet. But it was able to write the data into the excel sheet if i open the excel file when running the program.
    Can anyone please tell me what's wrong to the code?
    public int updateLog(String sheet, String no, String cpId, String CatId, String rbtCode, String rbt, String rbtName, String artistName, String price, String rbtFileName, String songId, String msg){
            int result = -1;
            try{
                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",Locale.ENGLISH);
                String actionDate = formatter.format(new Date());
                rbtName = rbtName.replaceAll("'", "''");
                artistName = artistName.replaceAll("'", "");
                String sql = "insert into [Sheet3$] (Code, CpID, CategoryID, RBTCode, RBT, RBTName, ArtistName, Price, RBTFileName, SongID, UploadStatus, FileUploadedDateTime) ";
                sql = sql + " values ('" + no + "', '" + cpId + "', '" + CatId + "', '" + rbtCode + "', '" + rbt + "', '" + rbtName + "', '" + artistName + "', '" + price + "', '" + rbtFileName + "', '" + songId + "', '" + msg + "', '" + actionDate + "')";
                System.out.println(sql);
                log.writeLog(sql);
                result = stmnt.executeUpdate(sql);
            } catch(Exception e){
                e.printStackTrace();
                log.printStackTrace(e);
            return result;
        public int openConnection(){
            int result = -1;
            try{
                Class.forName(dbDriver);
                c = DriverManager.getConnection(conStr + excelFilePath+";ReadOnly=0;");
                stmnt = c.createStatement();
            } catch(Exception e){
                e.printStackTrace();
                log.printStackTrace(e);
                return -1;
            return 1;
        }Thanks

    HI,
    i hv a doubt regarding reading / opening of a
    password protected Excel file using jxl( java ) .
    How to read / open a password protected Excel file
    thro Java (jxl ) program .plz let me know some
    example also .
    Regards,
    Ramesh P
    845935822cross posting !! answered here
    http://forum.java.sun.com/thread.jspa?threadID=710466&messageID=9507085#9507085

Maybe you are looking for

  • Adobe CC 2014 Photoshop and AI Crashing

    Hi, So every time I open either ps cc 2014 or ai cc 2014 they just crash on me and I get the lengthy unexpected error message. I'm running mac osx 10.9.5 and have a few thrird party extensions that could be the culprit. The really strange and annoyin

  • How to add multiple images to panel

    Hi, i am trying to add more than 1 image to a panel, but i cant work out how. have the following code, but it means i have to create a new panel each time. i only want to use 1 panel, and add images to this one panel. the images are transparent and i

  • Function to simulate PO pricing

    Hi, I am using function ME_PO_PRICE_SIMULATION to recalculate purchase rebate agreement in a querry. The FM didn't work if an article get a flag for deletion or a status which didn't allowed the purchase. Is there an other FM to simulate the purchase

  • VS 2012 cannot open SharePoint 2013 site

    Hi, I am using SP 2013, VS 2012. I am trying to create a new project - selected SharePoint 2013 Visual webpart project. In the site to connect, I added a site (which I am site collection Administrator) , and selected "Deploy as Farm solution". I adde

  • Field and tables hide

    i am doing  msc2n tcode. processorder type:  unrestricted type and restricted type fields not showing. after few days my techincal person do some work. after few days i was got a table and feilds. what is the solution. regards satish