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

Similar Messages

  • 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)

  • 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.

  • 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.

  • 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.

  • 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

  • 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

  • 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

  • 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 text file on command using trigger

    Hi there
    I'm kinda new to using Labview, and i seek some advices. 
    I've got this program, which is used to read from a usb-device (6215). It measures the voltage at an input channel on the usb-device, and processes it, and finally writes the data to a txt file. I want to control when it writes the data (only one instance/ measurement at a time) via a trigger. 
    The problem is, that the trigger does not work. It always writes to the file i have specified. Can anyone help me getting this right?
    Furthermore, if someone have any suggestions how to make the data in the text file more readable (i'dd suggest using colums - but how?) i would greatly appreciate it. Maybe converting to an exel-document could be the answer?
     Thank you in advance, Troels
    Ps:
    Hope you can see past the danish text 
    Attachments:
    Sensor.vi ‏12 KB

    Your true and false cases are identical and the file write is outside of the case statement. The boolean trigger does nothing. Why don't you try putting the file write inside the true case statement and nothing in the false case? You wouls also place the DAQmx Read inside the true case.
    If you are not going to use an event structure (but you should), place a Wait (ms) function inside the loop.

  • What's the best way to read/write data from a file (preferabl​y a *.txt file)?

    As in the title.  l have revived a couple of old VIs to read and write three numbers and a 1D array of clusters to/from a *.txt file.  The functionality is not very user friendly, and it would also be useful if one could open the text files (manually - not through LabVIEW) and still be able to see/understand what was there.
    I was wondering if anyone would be able to come up with a more efficient and/or user friendly method (compatible with lv6.1) 
    James
    Never say "Oops." Always say "Ah, interesting!"
    Attachments:
    Read Spec.vi ‏110 KB
    Write Spec.vi ‏58 KB

    My primary goal is to have something that works and is easy and comprehensive to operate.  Generating a human-readable file is just a bonus but would be nice if it could be achieved.
    I enclose pictures of the initial file dialog (for both loading and saving the data - referred to as Spec(s) from hence forth), and of the front panel screen seen when  a) loading a spec and  b) saving a spec.  In the file dialog, you have to already know the exact string to input else you'll just be told the file doesn't exist (applies for both loading and saving).  When saving a spec, you cannot see any files previously saved, nor even any previous specs saved within the file.  This means that one can unwittingly overwrite specs without realising it.
    I'm not sure if I've explained this very well, but the current functionality means that far too much can go wrong.  Additionally, if you forget the file name, you'll have no way of knowing what it should be (the data files are stored on a 'locked' part of our network accessible only by Admin or through the LabVIEW executable
    Never say "Oops." Always say "Ah, interesting!"
    Attachments:
    File Dialog.JPG ‏23 KB
    Select The Required Test Spec.JPG ‏10 KB
    Name of specification.JPG ‏6 KB

Maybe you are looking for

  • GetParameter() with more than one word

    hi all i have these statement in my Servlet String cust = rs.getString(1); out.println("<INPUT TYPE=radio NAME=cdnames VALUE="+ cust + ">"+ cust + "<br>"); out.println("<input type=submit>"); out.println("</form>"); String lastName = request.getParam

  • IOS4 on 3GS - photos cannot import to PC

    Had my iphone 3GS upgrade to iOS4, problem is that photos taken after the upgrade are not able to import to PC when i connect my iphone to PC. Photos taken after the upgrade are stored in camera roll , old photos were syc. to camera roll too. But whe

  • Detail table refreshing without partial trigger!!!

    Hi, my Jdeveloper version is 11.1.2.3.0 I have a master detail structure on my page and i have two weird behaviors (that i guess are related). I created the master detail tables in the classic way: I dragged the master data control and doped it on th

  • Time Machine screen is not opening

    When I select "Open Time Machine Preferences..." provided by the Time Machine icon or upper bar icon, the screen would not open. It was working perfectly! the other options: "Backup Now" and "Enter Time Machine" are working without a problem. I can p

  • AFP issue

    I have a Novel server 4.1 and some tiger machines. I need them to talk over AFP. Is there any way i could do that? Are there any third party softwares (AFP protocol) available for this?? Thanks in advance.   Mac OS X (10.4.3)