How to read a data file combining strings and data

Hello,
I'm having a data file combining strings and datas to read. I'm trying to read the filename, time, constants and comments into four seperate string indicators (the lines for the comments varies for different files). And read the data into a 2-D numeric array. How can I do this? Is there any function that can serch special characters in the spreadsheet file so I can exactly locate where I should start reading the specific data. The following is how the data file appears. Thank you very much.
Best,
Richard
filename.dat
14:59:00 12/31/2009
Sample = 2451
Frequency = 300, Wait time = 2500
Temperature = 20
some comments
some comments
some comments
some comments
some comments
7.0000E+2    1.5810E-5
7.0050E+2    1.5400E-5
7.0100E+2    1.5500E-5
7.0150E+2    1.5180E-5
Message Edited by Richard1017 on 10-02-2009 03:10 PM
Solved!
Go to Solution.

Hi,
     I'm fairly new to the NI forums too and I think you just have to wait longer.  Your post was done right.  I do a similiar function as to what you are talking about except I read in numbers from a file.  I create an ini file (just a notepad file of type *.ini) that is is set up with sections inside brackets [] and keys with whatever name followed by an = sign.  You may be able to use a *.dat file too, I just haven't.  Then the vi attached goes to that file and reads the keys from those sections.  You just repeat for the different sections and keys you want to read.  You can use similar provide VI's to write to that same file or create it.  Let me know how that works. 
Attachments:
Help1.ini ‏1 KB
Help1.vi ‏10 KB

Similar Messages

  • How to read a C structure with string and int with a java server using sock

    I ve made a C agent returning some information and I want to get them with my java server. I ve settled communication with connected socket but I m only able to read strings.
    I want to know how can I read strings and int with the same stream because they are sent at the same time:
    C pgm sent structure :
    char* chaine1;
    char* chaine2;
    int nb1;
    int nb2;
    I want to read this with my java stream I know readline methode to get the first two string but after two readline how should I do to get the two int values ?
    Any idea would be a good help...
    thanks.
    Nicolas (France)

    Does the server sent the ints in little endian or big endian format?
    The class java.io.DataInputStream (with the method readInt()) can be used to read ints as binary from the stream - see if you can use it.

  • How to read a xml file created dynamically and use it to to chart

    Hi
    I am using Fuisonchart in Flex to create 3D charts i have stored my xml in server path as "Data.xml",this xml will be generated when i click on a button,this button passes my http service and frame my xml.
    Xml values will get changed as per database values, my problem is my chart fetches xml of old generated values,and not the newly updated xml values,
    I need to send my xml atonce when it is updated and changed,Flex part gets that updated value only when i run the application second time.
    So please help me to update the chart atonce when it is updated.
    Thanks in Advance
    Gopinath.A,
    Softrware Developer
    Chennai.

    on button click, call sendGenerateService().
    private function sendGenerateService():void
    var hs:HTTPService = new HTTPService();
    hs.url = "generateXML.php?random="+Math.random();//generateXML.php will do necessavry stuff to update Data.xml
    hs.method = "post";
    hs.addEventListener(FaultEvent.FAULT,fault);
    hs.addEventListener(ResultEvent.RESULT,resultGenerateService);
    hs.send();
    private function resultGenerateService(e:ResultEvent):void
    var hs:HTTPService = new HTTPService();
    hs.url = "Data.xml?random="+Math.random();
    hs.method = "post";
    hs.addEventListener(FaultEvent.FAULT,fault);
    hs.addEventListener(ResultEvent.RESULT,resultGetXml);
    hs.send();
    private function resultGetXml(e:ResultEvent):void
    // feed your chart with result
    private function fault():void
    //fault handler

  • How to read a text file using Java

    Guys,
    Good day!
    Please help me how to read a text file using Java and create/convert that text file into XML.
    Thanks and God Bless.
    Regards,
    I-Talk

         public void fileRead(){
                 File aFile =new File("myFile.txt");
             BufferedReader input = null;
             try {
               input = new BufferedReader( new FileReader(aFile) );
               String line = null;
               while (( line = input.readLine()) != null){
             catch (FileNotFoundException ex) {
               ex.printStackTrace();
             catch (IOException ex){
               ex.printStackTrace();
         }This code is to read a text file. But there is no such thing that will convert your text file to xml file. You have to have a defined XML format. Then you can read your data from text files and insert them inside your xml text. Or you may like to read xml tags from text files and insert your own data. The file format of .txt and .xml is far too different.
    cheers
    Mohammed Jubaer Arif.

  • How to read multiple dat files.

    Hello Everyone!
    I am working on a project that requires one file that creates a JFrame with a current file title, JTextFields that accesses two .dat files and a JButton.
    The user clicks a JButton to cycle through the first sequential .dat file. When the end of the first file is reached the file is closed, the JFrame title is changed to the second file title as the user continues to click the JButton to continue on viewing the second file?s records, until the second reaches the end of file.
    The project requires using Try-Catches to catch the EOF exceptions and IOExceptions and Thread or Runnable.
    I have been able to get one file to read and display its records; however, researching back through my text on how to read/write to files I haven?t been able to determine how to get to the end of the file and proceed to the next file without triggering the EOFException. I have even tried multiple Try-Catches (one for each file within the actionPerformed method) and that ends up ignoring the first file records and only displays the second files records.
    This is a school project and we have only covered just the bare basics of Java over the last two months. So, any hints that anyone can provide can only be of what type of procedure will be needed or what procedure won?t help to complete the task, without giving away the solution.
    I have spent approximately 40 hours of study time on this project and believe that I have definitely run into a major snag.
    The following is the code I have so far:
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class StudentRead extends JFrame implements ActionListener
       private JLabel gradStudentList = new JLabel("GRADUATE Student List");
       private JLabel undergradStudentList = new JLabel("UNDERGRADUATE Student List"); 
       private Font bigFont = new Font("Helvetica", Font.ITALIC, 24);
       private JLabel userprompt = new JLabel("View the students");
       private JTextField idNumText = new JTextField(4); 
       private JTextField lastNameText = new JTextField(15);
       private JTextField firstNameText = new JTextField(15);
       private JButton viewRecordButton = new JButton("View Record");
       private JLabel idNumberLabel = new JLabel("ID Number"); 
       private JLabel lastNameLabel = new JLabel("Last name"); 
       private JLabel firstNameLabel = new JLabel("First name");
       private Container con = getContentPane();
       DataInputStream gradStudentInStream;
       DataInputStream undergradStudentInStream;
       public StudentRead()
          super("Read Student Records");
          try
             gradStudentInStream = new DataInputStream(new FileInputStream("GradStudents.dat"));
             undergradStudentInStream = new DataInputStream(new FileInputStream("UndergradStudents.dat"));
          catch(IOException e)
             System.err.println("File not opened");
             System.exit(1);
          setSize(325, 200);
          con.setLayout(new FlowLayout());
          gradStudentList.setFont(bigFont);
          con.add(gradStudentList);
          con.add(userprompt);
          con.add(idNumberLabel);
          con.add(idNumText);
          con.add(lastNameLabel);
          con.add(lastNameText);
          con.add(firstNameLabel);
          con.add(firstNameText);
          con.add(viewRecordButton);
          viewRecordButton.addActionListener(this);
          setVisible(true);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       public void actionPerformed(ActionEvent e1)
          String lastName, firstName;     
          int IdNum;
          try
             IdNum = gradStudentInStream.readInt();      
             lastName = gradStudentInStream.readUTF();
             firstName = gradStudentInStream.readUTF();
             idNumText.setText(String.valueOf(IdNum));
             lastNameText.setText(lastName);
             firstNameText.setText(firstName);
          catch(EOFException e2)
             closeFile();
             System.exit(0);
          catch(IOException e3)
             System.err.println("Error reading file");
             System.out.println("out");      
             System.exit(1);
       public void closeFile()
          try
             gradStudentInStream.close();
             System.exit(0);
          catch(IOException e)
             System.err.println("Error closing file");
             System.exit(1);
       public static void main(String[] args)
          StudentRead rsr = new StudentRead();
    }

    deepak_1your.com wrote:
    hi,
    If you want to read a file guarding yourself agianst exceptions....
    check this article.... the code presented in this article might suit your needs...
    [http://1your.com/fusion/infusions/articles/readarticle.php?article_id=17|http://1your.com/fusion/infusions/articles/readarticle.php?article_id=17]
    And how does that help with a DataInputStream?

  • How to read the data from Excel file and Store in XML file using java

    Hi All,
    I got a problem with Excel file.
    My problem is how to read the data from Excel file and Store in XML file using java excel api.
    For getting the data from Excel file what are all the steps i need to follow to get the correct result.
    Any body can send me the code (with java code ,Excel sheet) to this mail id : [email protected]
    Thanks & Regards,
    Sreenu,
    [email protected],
    india,

    If you want someone to do your work, please have the courtesy to provide payment.
    http://www.rentacoder.com

  • How to read the date and time information of a file by labview

    how to read the date and time information of a file by labview? for example, created time and modified time.
    Solved!
    Go to Solution.

    if you need to know the last modification date of file:-
    "Functions->File I/O->Advanced File Functions->File/Directory Info.vi"
    This vi returns the value of file's last modification date. This is returned as U32 number. To see it in MM/DD/YY format you must create the indicator, right-click on it and select "Format & Precision" item from drop-down menu. Then select "Time and Date" format there.
    Thanks as kudos only

  • How to read the data in excel sheet

    Dear sir,
    How to read the data in excel sheet when i recieve a data serial communication... ie i have store a data in excel such that
    Cell A       Cell B
       A           Apple 
       B           Ball
       C           Cat
       D           Doll
    when i recieve A from serial communication i have to display Apple, and when i recieve B i have to display Ball and so on.. 

    Hi, 
    I would recommend you to have a look at the VI attached. It makes use of a VI named 'Read from Spreadsheet' to read the row and column data from the tab delimited excel file. The read data is then searched for the Alphabet specified and finally returns you the corresponding string. The test file used to validate the operation of the VI is also attached. 
    Trust this would help you solve the issue. 
    Regards, 
    Sagar G Yadav | Application Engineer | National Instruments
    Attachments:
    read_from_excel.vi ‏10 KB
    Book1.txt ‏1 KB

  • How to read the properties file available in Server File structure in webdy

    hi all,
    I have developed one webdynpro application. In this application i need to access mdm server to continue. For getting the connection i need to pass the IP addresses.
    Can i have code  how to read the properties file which is residing in the server file. with out included along with the application. keeping some where in the file structure in the server. I want to read that properties file by  maintain the iP addresses and users in  properties file based on the key i want to read like below.
    servername="abcServer"
    username="john"
    password="test123"
    Please send me the code how to read this properties file from the file structure and how to read this values by key  in webdynpro application
    Regards
    Vijay

    Hi Vijay,
    You can try this piece of code too:
    Properties props = new Properties();
    //try retrieve data from file
    //catch exception in case properties file does not exist
    try {
             props.load(new FileInputStream("c:\property\Test.properties")); //File location
             String serverName = props.getProperty("servername"); //Similarly, you can access the other properties
             if(serverName==null)
               //....do appropriate handling
         }     catch(IOException e)
                   e.printStackTrace();
    Regards,
    Alka.

  • How to read the data in spectrum analyzer (Anritsu MS2661C) and put it in Excel using Labview

    Hi all, I'm new to using the labview, and I have some trouble doing my project using the labview software.
    I have been trying to use the spectrum analyzer (Anritsu MS2661C) which connect to computer using the GPIB connection.
    I have got the instrument driver which can write and control the instrument using Labview 2010.
    and my Question is how do read the data or result from the spectrum analyzer and send it to the microsoft excel?
    Do I need to use other software or programming to do this step?
    If anyone know how is this done, please let me know.
    Regards,
    Ery

    Hi ery,
    In order to send data that you have read in from an instrument to Excel, the most convenient way to do this would be to use our Report Generation Toolkit.  The Report Generation Toolkit is a very useful tool that allows you to interface to Microsoft Office software from LabVIEW, including Word and Excel.  I am not sure if you are familiar with this, but I have attached a link that explains more about the Report Generation Toolkit below.  
    Another way would be to use the Write To Spreadsheet File VI.  While this will store your data to a spreadsheet data file, it will not allow you to programmatically perform any Excel formatting like the Report Generation Toolkit offers.  I have also attached a link to some information on the Write To Spreadsheet VI below.  
    Also, be sure to check out the Example Finder in LabVIEW for a number of examples on how to write data to a spreadsheet file.  From LabVIEW, you can go to Help»Find Examples to launch the Example Finder.  From there, you can search for "spreadsheet," which should populate examples for use in different applications.  I hope this helps, ery.  Please let me know if you have any further questions about these!
    NI LabVIEW Report Generation Toolkit for Microsoft Office
    Write To Spreadsheet File VI 
    Taylor G.
    Product Support Engineer
    National Instruments
    www.ni.com/support

  • How to read an xml file from headers

    Hi ,
    I am not getting how to read an xml file sent by client device in header to server.
    Thankx.

    There is a getHeader() in HttpServletRequest interface
    String locationURL=request.getHeader("Location");If URL of your file was set in Location attribute of header.
    Edited by: ngpgeeta on Dec 19, 2008 8:03 AM

  • How to read an html file and replace a text using text_io

    hi,
    i want ro read an html file using text_io and replace a particular text with a new text
    eg: i want to replace a text called "data.js" and with "maps.js"
    how do i do this?

    You have to write your own code to do that. TEXT_IO is just a low level text file interface.
    You need to read in all the text, save it in some internal format (array of varchar2's maybe or in the DB) and then perform a search on the text you have read in, find out where the instances of "data.js" are located and substitute them with "maps.js" After that you need to write to a new file and delete the old one. There is no way to search and replace inside the existing file (what's sometimes referred to as 'in-place' substitution).
    See the help section called About the TEXT_IO package for an overview of how it works and some code examples.

  • How to read from properties file

    Hi,
    I am using JSR 168.
    while creating a new portlet, a folder gets created with the name as "portlet". Under which is resource package and <PortletName>Bundle.java.
    pls tell me how to read from .properties file.
    waiting eagerly for some reply
    Thanks & Regards,
    HP
    Edited by: user9003827 on Apr 13, 2010 3:42 AM

    I think i have mixed it up :)
    I have looked at it again and believe you are using regular JSP portlets.
    Can you tell what you want to achieve by reading .properties file. Are you meaning the preferences of the portlet or what exactly are you trying to do?
    Reading propertie files is easy:
    // Read properties file.
    Properties properties = new Properties();
    try {
        properties.load(new FileInputStream("filename.properties"));
        String myKey = properties.getProperty("yourKey");
    } catch (IOException e) {
    }Edited by: Yannick.O on 13-Apr-2010 05:52

  • How to read a data from USB port using JAVA

    hi all,
    i need to know how to read a data from USB port using java. any API are available for java ?.........please give your valuable ideas !!!!!!!!!
    Advance Thanks!!

    You can do this. Please use this link
    [http://www.google.co.in/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=uHu&q=java+read+data+from+usb+port&btnG=Search&meta=&aq=f&oq=]
    What research did you do of your own? Have you done some testing application and tried yourself??

  • How to read several text files at a time

    Dear all
          Read and write one text file is not a problem, but  what confusies me is how to read several text files at one time, in the meanwhile,
    is it possible to display the name of the text file?
    For example, assuming I want to load file" cha 1, cha 2 , cha 3, " at one time and show their names, how to hadle with it
    I have reviewed some files and it is not helpful

    Either with a 'for' loop like in the lib you have attached, or like this attached VI
    that's it
    Message Edited by devchander on 05-30-2006 05:11 AM
    Attachments:
    MULTIPLE READ.vi ‏44 KB

Maybe you are looking for