Write array into txt file

Hi Guys!
I need a VI which writes the content of an array into a txt file.
I have an array like this:
Peti    Teri
Zoli    Hajni
Tomi    Heni
Pali    Robi
In the file the first line should be a full timestamp (date, time), and then would come the content of the array. The name of the file would also be a timestamp.
Thank you for your help in advance!

Hi Victronica and welcome to NI Forums!
If you have some custom data, then it is up to ou to tell excel how to interpret said data (what information to put where, etc.) A simple solution would be to flatten your cluster elements into strings, and write those strings into an excel sheet using ActiveX. An example on how to write a table of strings is available in the example finder, and I also have it attached here in LabVIEW 2013.
Kind regards:
Andrew Valko
National Instruments Hungary
Attachments:
Excel - Write Table.vi ‏17 KB

Similar Messages

  • Write string array into cfg file

    Hi, everybody.
    I faced the problem to write array into cfg file. I am trying to put many items in a key. It should look like
    [Section1]
    Key1=el_1, el_2,el_3,.............el_n.
    each element is string of 105 characters. Everything works fine when I save the only one el_1 or multiple for the  first time, however, when I am trying to update values in a key section some extra strings appear in a file. My VI is attached.
    Thanks in advance

    Do you realize that your spreadsheet string only writes the following:
    1111111111
      2222222222222222
     33333333333333333333
    The way you wrote your VI, it sends the entire string above to the value for Write Key.vi.
    Do you realize that value is for the data type only?  So I'm not sure what you want to do....
    Without describing the problem you are having, can you describe what you actually want to do?
    R
    Message Edited by JoeLabView on 07-22-2008 11:49 AM
    Attachments:
    confused.PNG ‏26 KB

  • How to get all paragraphs style and their fonts of a  indesign file and write all info with para info into txt file with scripting

    how to get all how to get all paragraphs style and their fonts of a  indesign file and write all info with para info into txt file with scriptingstyle and their fonts of a  indesign file and write all info with para info into txt file with scripting

    I write the script this one works
              var par=doc.stories.everyItem().paragraphs.everyItem().getElements();
      for(var i=par.length-1;i>=0;i--)
           var font=par[i].appliedParagraphStyle.name;
            var font1=par[i].appliedFont.name;
             var size=par[i].pointSize;
            WriteToFile (par[i].contents  +   "\r" +  "Style  : " + font  + "\r" +  "FONT1  : " + font1  + "\r" +  "Size  : " + size  + "\r", reportFilePath);
                            function WriteToFile(text, reportFilePath) { 
        file = new File(reportFilePath); 
        file.encoding = "UTF-8"; 
        if (file.exists) { 
            file.open("e"); 
            file.seek(0, 2); 
        else { 
            file.open("w"); 
          file.writeln(text);  
        file.close(); 
    Thanks for all your support

  • 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

  • Java.io.NotSerializableException when overwrite the JTable data into .txt file

    hi everyone
    this is my first time to get help from sun forums
    i had java.io.NotSerializableException: java.lang.reflect.Constructor error when overwrite the JTable data into .txt file.
    At the beginning, the code will be generate successfully and the jtable will be showing out with the data that been save in the studio1.txt previously,
    but after i edit the data at the JTable, and when i trying to click the save button, the error had been showing out and i cannot succeed to save the JTable with the latest data.
    After this error, the code can't be run again and i had to copy the studio1.txt again to let the code run 1 more time.
    I hope i can get any solution at here and this will be very useful for me.
    the following is my code...some of it i create it with the GUI netbean
    but i dunno how to attach my .txt file with this forum
    did anyone need the .txt file?
    this is the code that suspect maybe some error here
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    String filename = "studio1.txt";
              try {
                  FileOutputStream fos = new FileOutputStream(new File(filename));
                  ObjectOutputStream oos = new ObjectOutputStream(fos);
                   oos.writeObject(jTable2);
                   oos.close();
              catch(IOException e) {
                   System.out.println("Problem creating table file: " + e);
                   return;
              System.out.println("JTable correctly saved to file " + filename);
    }the full code will be at the next msg

    this is the part 1 of the code
    this is the full code...i had /*....*/ some of it to make it easier for reading
    package gui;
    import javax.swing.*;
    import java.io.*;
    public class timetables extends javax.swing.JFrame {
        public timetables() {
            initComponents();
        @SuppressWarnings("unchecked")
        private void initComponents() {
            jDialog1 = new javax.swing.JDialog();
            buttonGroup1 = new javax.swing.ButtonGroup();
            buttonGroup2 = new javax.swing.ButtonGroup();
            buttonGroup3 = new javax.swing.ButtonGroup();
            buttonGroup4 = new javax.swing.ButtonGroup();
            jTextField1 = new javax.swing.JTextField();
            jLayeredPane1 = new javax.swing.JLayeredPane();
            jLabel6 = new javax.swing.JLabel();
            jTabbedPane1 = new javax.swing.JTabbedPane();
            jScrollPane3 = new javax.swing.JScrollPane();
            jTable2 = new javax.swing.JTable();
            jScrollPane4 = new javax.swing.JScrollPane();
            jTable3 = new javax.swing.JTable();
            jButton1 = new javax.swing.JButton();
            jButton2 = new javax.swing.JButton();
    /*       org.jdesktop.layout.GroupLayout jDialog1Layout = new org.jdesktop.layout.GroupLayout(jDialog1.getContentPane());
            jDialog1.getContentPane().setLayout(jDialog1Layout);
            jDialog1Layout.setHorizontalGroup(
                jDialog1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 400, Short.MAX_VALUE)
            jDialog1Layout.setVerticalGroup(
                jDialog1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 300, Short.MAX_VALUE)
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            jLayeredPane1.add(jLabel6, javax.swing.JLayeredPane.DEFAULT_LAYER);
            String filename1 = "studio1.txt";
            try {
                   ObjectInputStream ois = new ObjectInputStream(new FileInputStream(filename1));
                   jTable2 = (JTable) ois.readObject();
                   System.out.println("reading for " + filename1);
              catch(Exception e) {
                   System.out.println("Problem reading back table from file: " + filename1);
                   return;
            try {
                   ObjectInputStream ois = new ObjectInputStream(new FileInputStream(filename1));
                   jTable3 = (JTable) ois.readObject();
                   System.out.println("reading for " + filename1);
              catch(Exception e) {
                   System.out.println("Problem reading back table from file: " + filename1);
                   return;
            jTable2.setRowHeight(20);
            jTable3.setRowHeight(20);
            jScrollPane3.setViewportView(jTable2);
            jScrollPane4.setViewportView(jTable3);
            jTable2.getColumnModel().getColumn(4).setResizable(false);
            jTable3.getColumnModel().getColumn(4).setResizable(false);
            jTabbedPane1.addTab("STUDIO 1", jScrollPane3);
            jTabbedPane1.addTab("STUDIO 2", jScrollPane4);
            jTextField1.setText("again n again");
            jLabel6.setText("jLabel5");
            jLabel6.setBounds(0, 0, -1, -1);
            jButton2.setText("jButton2");
            jButton1.setText("jButton1");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
          

  • When i am trying to extract Dimension into .txt file. I am getting error.

    Hi All,
    When i am trying to extract the Essbase Dim into .txt file, i am getting below error.
    Please find the details.
    V10.1.3.5.0 and MySql server as database.
    com.sunopsis.sql.c: com.sunopsis.jdbc.file.FileDriver
         at com.sunopsis.sql.SnpsConnection.a(SnpsConnection.java)
         at com.sunopsis.sql.SnpsConnection.t(SnpsConnection.java)
         at com.sunopsis.sql.SnpsConnection.connect(SnpsConnection.java)
         at com.sunopsis.sql.SnpsQuery.updateExecStatement(SnpsQuery.java)
         at com.sunopsis.sql.SnpsQuery.executeUpdate(SnpsQuery.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execStdOrders(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSqlI.treatTaskTrt(SnpSessTaskSqlI.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
         at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
         at com.sunopsis.dwg.cmd.e.i(e.java)
         at com.sunopsis.dwg.cmd.h.y(h.java)
         at com.sunopsis.dwg.cmd.e.run(e.java)
         at java.lang.Thread.run(Thread.java:662)
    Please help me in this issue.
    Regards,
    Krish
    Edited by: 897734 on Dec 20, 2011 2:40 AM

    If you think a file doesn't exists when you think it should, you can use code like this to print out what files are there:
    import java.io.*;
    public class Periscope {
        public static void check(File file) {
            if (file.exists()) {
                System.out.println("file exists: " + getPath(file));
                System.out.println();
                System.out.println("DUMP:");
                System.out.println();
                dump(file, "");
            } else {
                System.out.println("file does not exist: " + getPath(file));
                goUp(file);
        static void goUp(File file) {
            File parent = file.getAbsoluteFile().getParentFile();
            if (parent == null) {
                System.out.println("file does not have a parent: " + getPath(file));
            } else {
                check(parent);
        static void dump(File file, String indent) {
            System.out.println(indent + getPath(file));
            File[] children = file.listFiles();
            if (children != null) {
                indent += "    ";
                for(File child : children) {
                    dump(child, indent);
        static String getPath(File file) {
            try {
                return file.getCanonicalPath();
            } catch (IOException e) {
                e.printStackTrace();
                return file.getName();
        public static void main(String[] args) {
            check(new File("foo.bar"));
    }

  • Write arrays into a text file in different columns at different times

    Hi,
              I have a problem write data into a text file. I want to write 4 1D arrays into a text file. The problem is that I need to write it at different time and in different column (in other word, not only append the arrays).
    Do you have an idea to solve my problem?
    Thank you

    A file is long a linear string of data (text). In order ro insert columns, you need to rewrite the entire file, because colums are interlaced over the entire lenght of the file.
    So:
    read file into 2D array
    insert columns using array operations
    write resulting 2D array to file again.
    (Only if your colums are guaranteed to be fixed width AND you know the final number of colums, you could write the missing columns as spaces and then overwrite later. Still, it will be painful and inefficient, because column data are not adjacent in the file.)
    LabVIEW Champion . Do more with less code and in less time .

  • Write records into a file

    CREATE OR REPLACE PROCEDURE test IS
        cursor    cur is
          select dname||';'||loc dnlo
          from   dept;
      rec          cur%ROWTYPE;
      v_returncode number;
    BEGIN
       open cur;
       loop
           fetch cur into rec;
           exit when cur%notfound;
           v_returncode:= write_file(rec.dnlo);
           dbms_output.put_line(rec.dnlo);
       end loop;
       close cur;
    END test;
    SQL> exec test
    ACCOUNTING;NEW YORK
    RESEARCH;DALLAS
    SALES;CHICAGO
    OPERATIONS;BOSTON
    SALES;LAS VEGAS
    PL/SQL-Prozedur wurde erfolgreich abgeschlossen.
    SQL> The program wrote 5 records into the file.txt (5 calls). Normally i must write
    at about 2 million records into the file. It is possible, to write the records into
    the file with one call, like a array or a ref_cursor (input parameter of the function write_file) instead of calling the function 2 millon times in a loop?
    Message was edited by:
    mad

    Couldn't help commenting cos that has got to be one of the best drive/folder name combinations I've seen in a long time. :))
    v_FileHandle:= UTL_FILE.FOPEN('s:\hit', v_FileName, p_FileModus, C_MAXLINESIZE);Seriously though, when working with UTL_FILE you should use directory objects to ensure proper security... note...
    The UTL_FILE_DIR parameter has been deprecated by oracle in favour of direcory objects because of it's security problems.
    The correct thing to do is to create a directory object e.g.:
    CREATE OR REPLACE DIRECTORY mydir AS 'c:\myfiles';Note: This does not create the directory on the file system. You have to do that yourself and ensure that oracle has permission to read/write to that file system directory.
    Then, grant permission to the users who require access e.g....
    GRANT READ,WRITE ON DIRECTORY mydir TO myuser;
    Then use that directory object inside your FOPEN statement e.g.
    fh := UTL_FILE.FOPEN('MYDIR', 'myfile.txt', 'r');Note: You MUST specify the directory object name in quotes and in UPPER case for this to work as it is a string that is referring to a database object name which will have been stored in uppercase by default.
    ;)

  • 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 write csv or txt file through utl_file with UTF-8 Encoding

    Hi All,
    I need your help to write the data from DB to csv or txt file with UTF-8 encoding through utl_file.
    Database character set:AL32UTF8
    Database version:10G
    All the columns in the DB are of varchar2 type.
    Please let me know if there is any way of doing it.

    What was wrong with the info provided in the link(s) given?
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions027.htm#SQLRF00620]

  • 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

  • Insert line break into .txt file

    Alright, so I am writing out to a simple .txt file, and I
    need to force a line break in it. My immediate thought is to use
    "\n" as that is a line break. So, I write it out to the text file,
    and instead of a line break, I see the "complex character" symbol
    (you know, that square that shows up with unknown characters). I
    have tried the various ASCII values to no avail, tried \r, even
    tried copy-pasting a line break in from notepad. Nothing seems to
    be working for me. How do I do this?
    _logFile = "\n";
    stream = new FileStream();
    stream.open(file,FileMode.WRITE);
    stream.writeUTFBytes(_logFile);
    stream.close();

    in windows use "\r\n"
    i.e. _logFile = "\r\n";

  • Copying console output into *.txt files

    Basically, I am having trouble creating *.txt files and copying System.out.println(" data "); into these *.txt files. I've tried FileInputStream and FileOutputStream, but these haven't worked. I've also tried doing this on both Unix and Windows environments.
    Can anyone help?

    Hi,
    If you want to do this from within your program you'll need to redirect the system output:
    System.setOut (new PrintStream((OutputStream) new FileOutputStream ("C:/test.txt")));
    System.out.println ("test ok");
    Kurt.

  • How can i put a system.out.println into txt file

    i want to generate a txt file instead of system.out.println. for the output How can i do that and what code can i use for that??
    Edited by: crystalarun on Oct 14, 2007 11:40 AM

    suppose u ant output in "Output.txt"
    then code can be
    PrintStream out = new PrintStream(new FileOutputStream("Output.txt"));
    System.setOut(out)

  • Write and read txt files and catch the exceptions

    hey everyone, im in a bit of a bind. im trying to set up this try catch statement. here is what i have for code so far.
    import java.util.Scanner;
    import java.io.*;
    public class Warning
        //   Reads student data (name, semester hours, quality points) from a
        //   text file, computes the GPA, then writes data to another file
        //   if the student is placed on academic warning.
        public static void main (String[] args)
         int creditHrs;         // number of semester hours earned
         double qualityPts;     // number of quality points earned
         double gpa;            // grade point (quality point) average
         String line, name, inputName = "students.dat";
         String outputName = "warning.dat";
         try
              Scanner FileScan1 = new Scanner (new File("students.dat"));
              // Set up scanner to input file
              // Set up the output file stream
              // Print a header to the output file
              outFile.println ();
              outFile.println ("Students on Academic Warning");
              outFile.println ();
              // Process the input file, one token at a time
              while (FileScan1.hasNext())//there is another line...
                  {               // Get the credit hours and quality points and
                   // determine if the student is on warning. If so,
                   // write the student data to the output file.
              // Close output file
         catch (FileNotFoundException exception)
              System.out.println ("The file " + inputName + " was not found.");
         catch (IOException exception)
              System.out.println (exception);
         catch (NumberFormatException e)
              System.out.println ("Format error in input file: " + e);
    }I am pretty sure the layout is good to go, but first and foremost that try statement is hanging me up. Could someone give me some suggestions about how i should set this up.
    i want to read in this students.dat file, then output another file called warning.dat.
    Thanks i really appreicate the help.

    no, i was really hoping to just see if the way it is
    set up it will be doable, that way i wouldn't be
    working on code that was impossiable to sort through
    properlyFair enough.
    One thing I'd suggest is that if you're really basically only going to be printing the exceptions, and since that is the top-level method (main) --
    I'd instead just add some "throws" clauses to main, get rid of the try/catch stuff, and just let the VM handle the exceptions for you. It will print them, just like you're doing, except that it will also print the stack traces, which you are not doing.
    If you're going to handle exceptions, it's better to actually do something about them rather than just print them - otherwise you might just as well let the runtime do that for you.

Maybe you are looking for

  • Need help with query that can look data back please help.

    hi guys i have a table like such CREATE TABLE "FGL"     "FGL_GRNT_CODE" VARCHAR2(60),     "FGL_FUND_CODE" VARCHAR2(60),     "FGL_ACCT_CODE" VARCHAR2(60),     "FGL_ORGN_CODE" VARCHAR2(60),     "FGL_PROG_CODE" VARCHAR2(60),     "FGL_GRNT_YEAR" VARCHAR2

  • IP - Various problems with BEX Analyser - help would be nice

    Hi, we use IP in combination with BEX analyser. We experience certain problems. Does anyone experienced the same issues mentioned below: 1) if a planning function is executed, it is executed twice when your cursor is within the query itself. If it is

  • How to call a exe or bat file from java program

    hi, i actually want to know that how to call a exe or bat file from program so that i can run them parallely.

  • Problems in fetching date to be set in setWhereClause

    Hi, In my OAF page there is a date combo which is populated by a VO. By default the date combo shows the date in a format 03-Sep-2011. So when I set the where clause in my code before doing vo.executeQuery, I set the where clause in as: vo.setWhereCl

  • Replace Profile Files -- Restart Fails

    Dear all We're on SAP Netweaver2004s, having following issue: The Profile Files (Default/Start/Instance) have been deleted and recreated with other names in RZ10. Saving and activating was fine, but after restart of the server, the instance is no lon