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 .

Similar Messages

  • Adding large arrays to a text file as new columns

    I am trying to merge several large text data files into a single file in Labview 8.0.  The files are too large to read in all at once (9-15 million lines each), so decided I need to read them in as smaller chunks, combine the arrays, and write them to a new file.
    The reason there are three separate data files was for speed and streaming purposes in the project, and the users wanted the raw, unadulterated data written to file before any kind of manipulation took place. 
    My VI:
    1.  Takes a header generated from another VI and writes it to the output file.
    2.  Creates a time column based on sample rate and the total number of data points
    3.  Reads in 3 files that each have text data (each data point is 9 bytes wide, there are up to 15 million data points per file.
    4.  Each iteration of the for loop writes a chunk of 10 to 100 thousand points (Somewhere in there seems to be the fastest it will do), formatted with the time column on the left, then the three data columns, until it's done.  I haven't quite figured out how to write the last iteration if there are fewer data points than the chunk size.
    Anyways, the main thing I was looking for was suggestions on how to do this faster.  It takes about a minute per million points on my laptop to do this operation, and though I recognize it is a lot of data to be moving around, this speed is painfully slow.  Any ideas?
    Attachments:
    Merge Fast Data.vi ‏67 KB

    Thanks for the tip.  I put the constants outside the array and noticed a little improvement in the speed.  I know I could improve the speed by using the binary file VI's but I need the files as tab delimited text files to import them into MATLAB for another group to do analysis.  I have not had any luck converting binary files into text files.  Is there an easy way to do that?  I don't know enough about binary file systems to use them.  I looked at the high speed data logger examples but they seemed complicated and hard to adapt to what I need to do.  Creating the binary header file seemed like a chore. 
    I am up for more advice on the VI I posted, or suggestions on different ways to convert a binary file to a MATLAB readable text file.
    Thanks!

  • ORA-06521: PL/SQL: Error mapping function while writting into a text file

    Hi,
    I'm getting an errror ORA-06521: PL/SQL: Error mapping function while trying to write data into a text file.
    I'm using the following code:
    --To create a new directory
    create or replace directory temp as 'C:/temp';
    declare
                    l_str varchar2(1000);
                    output_file utl_file.file_type;
                    cursor test_write_cur is
                         select EMPNO,ENAME,JOB,SAL,HIREDATE
                           from EMP
                         where DEPTNO=30;
    begin
               output_file := utl_file.fopen('TEMP','TESTFILE.txt','w');
               for test_write_rec IN test_write_cur
               loop          
                l_str :=     test_write_rec.EMPNO||'^'||test_write_rec.ENAME||'^'||test_write_rec.JOB||'^'||
                         test_write_rec.HIREDATE||'^'||test_write_rec.SAL||chr(10);
                utl_file.put_line(output_file,l_str);
                     end loop;                                                                           
               utl_file.fclose(output_file);
    end;Please suggest me if i'm wrong.
    Thanks & Regards,
    Sanket Mishra

    Dear Sanket,
    I think you are need use TO_CHAR() function
      to_char(test_write_rec.EMPNO) ,
      to_char(test_write_rec.HIREDATE,'DD.MM.YYYY')
      to_char(test_write_rec.SAL)

  • Grabbing numbers from an array of type double and outputting them into a text file

    In a program im creating i need to save some coordinates of a micropositioner i have into a text file,
    I have the coordinates saved into an array that has 6 digits of precision (6 places after the decimal point).
    I use the number to string conversion and wire that into the write to text file function in labview.  When i open the file
    the numbers that are only displayed are the ones to the left of the decimal point.  I know the number to decimal string function
    rounds the values so if i were to input 3.111111 it would only output the string "3" instead of "3.111111" . 
    So to get all the digits onto the file without rounding i multiplied the number by 10^6 but the decimal point will be lost at that point.
    Is there anyway i can convert numbers into strings without labview rounding to the nearest whole number also without having to multiply by 10^6 and without having to expect the user to know that the coordinates saved in a file are multiplied by an order of magnitude of a million ? 

    ed oh i guess i just missed that function on the pallete after i saw that the function went from number to hex, octal, etc. i assumed that the rest on that row would be some sort of conversion to a different base number, haha thanks.

  • Write Query Results into a text file

    Hello All,
    In SAP B1 Query Generator I'm trying to write the results of a query into a text file (.txt). I've tryed with queryout but it doesn't work.
    What I want is something like this:
    SELECT * FROM TABLE queryout "C:/textfile.txt"
    Any sugestions?
    Thanks in advance,
    Miguel Barbosa

    Hello All,
    Since yesterday and due to your help, I've found how to solve my problem.
    This post is only to share with you and with the others users of Expert Forums how to Write the results of an SQL Query in SAP Business One to a Text File without making it by exportation.
    Requested Text File by customer:
    Document type in R/3 If Invoice -- 'Z100' - Position 1 to 4 - 4 characters
    Supplier Code -- dbo.Table.CardCode -- Position 5 to 15 - 10 characters
    Item Code -- dbo.Table.ItemCode -- Position 11 to 25 - 14 characters
    Client Code -- dbo.Table.CardCode -- Position 26 to 36 - 10 characters
    Client Name -- dbo.Table.CardName -- Posiiton 37 to 100 - 63 characters
    Fixed Blank Field -- ' ' -- Position 101 to 120 - 19 blank spaces
    Quantity -- dbo.Table.Quantity -- Position 121 to 140 -- 19 characters
    Unit Price -- dbo.Table.PriceBefDi -- Position 141 to 160 -- 19 characters
    If Invoice Fixed identifier -- 'Z01' -- Position 161 to 163 -- 3 characters
    Fixed Blank Field -- ' ' -- Position 164 to 220 -- 56 characters
    Document Date -- dbo.Table.DocDate -- Position 221 to 229 - 8 characters
    Delivery Date -- dbo.Table.ActDelDate -- Position 230 to 238 - 8 characters
    Sales Order Number - dbo.Table.DocNum -- Position 239 to 260 - 21 characters
    Delivery Number - dbo.Table.DocNum -- Position 261 to 282 - 21 characters
    Follows the code:
    EXEC master..xp_cmdshell'bcp
    SELECT DISTINCT
    ''Z100''
    + ''ZP00002091''
    + IsNull(Convert(nVarChar(44), Cast(T0.DocNum As Numeric(38, 0))), '''')
    + ''PTAP''
    + ''          ''
    + ((LTRIM(RTRIM(T1.U_NumConc)))) + SPACE(10-LEN(LTRIM(RTRIM(T1.U_NumConc)))) + ((LTRIM(RTRIM(T3.BaseRef)))) + SPACE(10-LEN(LTRIM(RTRIM(T3.BaseRef))))
    + ''                    ''
    + ''Z02''
    + CONVERT(varchar(10), T1.ActDelDate, 112)
    + CONVERT(varchar(10), T0.DocDate, 112)
    + ''    ''
    + IsNull(Convert(nVarChar(44), Cast(T1.BaseRef As Numeric(38, 0))), '''')
    + ((LTRIM(RTRIM(T1.ItemCode)))) + SPACE(18-LEN(LTRIM(RTRIM(T1.ItemCode))))
    + ''0'' + REPLACE(SPACE(12-LEN(CONVERT(varchar(12), CAST(T1.Quantity AS NUMERIC (38,3))))),'' '',''0'') + REPLACE(((LTRIM(RTRIM(CONVERT(NUMERIC(38,3),T1.Quantity))))),''.'','''')
    + ''0'' + REPLACE(SPACE(12-LEN(CONVERT(varchar(12), CAST(T1.PriceBefDi AS NUMERIC (38,2))))),'' '', ''0'') + REPLACE(((LTRIM(RTRIM(CONVERT(NUMERIC(38,2),T1.PriceBefDi))))) ,''.'','''')
    + ''ZPHA''
    + ''          ''
    + ''  ''
    + ''                         ''
    + ((LTRIM(RTRIM(T4.CardName)))) + SPACE(69-LEN(LTRIM(RTRIM(T4.CardName))))
    + ''                        ''
    + CONVERT(varchar(10), T0.DocDate, 112)
    + ''               ''
    FROM
    JFOTST.dbo.OINV T0
    INNER JOIN JFOTST.dbo.INV1 T1 ON T0.DocEntry = T1.DocEntry
    INNER JOIN JFOTST.dbo.ODLN T2 ON T2.DocNum=T1.BaseRef
    INNER JOIN JFOTST.dbo.DLN1 T3 ON T3.DocEntry=T2.DocEntry
    INNER JOIN JFOTST.dbo.OCRD T4 ON T1.U_NumConc=T4.AddId
    WHERE T0.CardCode=''C52''
    queryout "c:\text1.txt" -c -T -x'
    Note that in this code everytime you need to use the symbol ' you have to doble it like ''Fixed Text''.
    Be aware that there is one UDF so if you try to make this query run in your SB1 you will have to create a UDF called U_NumConc in the document lines.
    Database usage:
    JFOTST.dbo.OINV T0
    JFOTST.dbo - Database Name.
    OINV - Table
    T0  - Alias
    For any doubts I'll be available to help.
    Once again thank you very much for all your help.
    Together we are stronger!
    Kind Regards,
    Miguel Barbosa
    Edited by: Miguel Barbosa on Aug 18, 2009 12:09 PM
    Edited by: Miguel Barbosa on Aug 18, 2009 12:10 PM

  • 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

  • Reading in an array from a text file

    I'm trying to use a text file to load in some configuratin
    data (using actionscript 3) I have it working ok for simple stuff
    like gamename=Chess&gamescore=100 , etc... but some of the data
    needs to be in an array. Can someone please point me in the right
    direction to how I can read in an array from a text file?
    Thanks!

    the easiest way is to create a string with the (soon-to-be)
    array elements separated by a delimiter (like a double comma). read
    in your string, then use the split() method of strings to split
    your string into an array.

  • How to output a query results into a text file

    How to output a query results into a text file instead of outputing it to the screen..
    is there a way for us to write a SQL query which specifies to output the query results to a text file.
    Pls let me know how to do it
    Thanking u in advance
    regards
    Muraly

    Muraly,
    If you are using SQL*Plus 8.1.6 or later, you can also spool output to a file in HTML format, eg
    SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON
    SPOOL c:\temp\report.html
    SELECT DEPARTMENT_NAME, CITY
    FROM EMP_DETAILS_VIEW
    WHERE SALARY>12000;
    SPOOL OFF
    SET MARKUP HTML ENTMAP OFF
    In iSQL*Plus 9.0.1 (the browser-based interface to SQL*Plus) onwards, you can also send the HTML output to a new web browser window, or an html file -- much easier than the command line method.
    Alison

  • Create and write form output to text file

    HI am pretty new to this and have a prob.
    I have 10 fields in my form submitting which i need to create and write the form field values into an xml fil..this file is further used for other read write transactions.
    Can somebody help creating and writing data into the text file with code (if u have it handy).
    Thanks for the help in anticipation

    File f = new File("/path/to/output.txt");
    BufferedWriter bw = new BufferedWriter(new FileWriter(f));
    String inputData = null;
    while(true){
      inputData = //whatever data you need
      bw.write(inputData);
    bw.flush();
    bw.close();
    f.close;
    // All this should be in a try{}catch(IOException ioe){}

  • Read data from db and write it into the txt file

    hi all
    could anyone please help me regarding the following:
    i would like to read the data from database using sql query and the write the data into a text file.
    I am able to connect the db, run the query, create file...but not knowing how to write the data into the file.
    could anyone please help me out.
    thanks in advance
    regards
    sasasa
    Edited by: sasasa on Sep 14, 2009 8:57 AM

    i would like to read the data from database using sql query and the write the data into a text file.
    I am able to connect the db, run the query, create file...but not knowing how to write the data into the file.
    There must be something that I am missing.
    How is it possible to be able to navigate JDBC, run a query and create a file but not know how to write to it?

  • Scheduling multiple tab BO XI3 report needs to save into multiple text file

    Hi,
    I have BO XI 3 Desktop Intelligence reports, those reports contains multiple tabs. Once after scheduling these reports the output needs to save as different text files (each tab as separate text file). Generally when select output as text file we will get the text file with the data of current tab, but in this scenario I want all the tabs data into different text files. I guess we can do this with macro. But I am not good in macro development, hope somebody can help me.
    Could you please help out for the same!
    Thanks,
    Rama

    Thanks Dan.. I made chenges in code as per your suggestion.. its working fine in DeskI -> local PC
    But this is not working in InfoView level... when i scheduled the same report its not saving into multiple text files... can you please have look...
    macro code as follows:-
    Public Sub SaveAsText()
    Dim StrTxtPath As String
    Dim BusDoc As busobj.Document
    Set BusDoc = ThisDocument
    Dim BusRep As Report
    Dim I As Integer
    On Error GoTo ErrHandler
    'StrTxtPath = "
    xxxx.xxx.xxx.com\common\Reporting\"
    StrTxtPath = "D:\Business Objects\Test_Macro\"
    For I = 1 To BusDoc.Reports.Count
    Set BusRep = BusDoc.Reports.Item(I)
    BusRep.ExportAsText (StrTxtPath & BusRep.Name)
    Next I
    ErrHandler:
    Exit Sub
    End Sub
    When i run this macro through DeskI.. its saving the report as multiple .txt files with respective number of tabs... but the same thing is not working when i tried in scheduling...
    Can you please suggest me what are the changes needs to be done...
    Thanks in Advance
    Thanks,
    Rama

  • Write data to multiple text files after specific size

    Hello,
    I wrote a code that contineously writes data to  a text file. The problem is I am running this VI for long time and therefore this text file is being bigger in size e.g. more than 10MB. I want to split writing data in this text file after max 1MB size. Can anyone help ????
    thanks in advance.

    CMW.. wrote:
    You could use the "File/Directory Info Function" in the Advanced File VIs and Function palette to check the size. If the file is too big. close it and create a new one.
    I would use the Get File Position since this won't cause Windows to have to do so much.  Assuming you are just writing and not setting the file position manually, this will return the size of the file in bytes (file position will always be at the end of the file).
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Download Internal Table into a Text File in BSP?

    I have an internal table which i need to download into my local pc. I know i can not use FM gui_download. Could some one please post code on how to download the internal table into a text file in BSP. Also i am not sure if i can use save dialog FM. Also need suggestion on which FM to use for save dialog which tells where to save the file.
    Any help will be appreciated.
    Thanks
    Nahman

    This might be a good starting point.
    <a href="/people/thomas.jung3/blog/2004/09/02/creating-a-bsp-extension-for-downloading-a-table">/people/thomas.jung3/blog/2004/09/02/creating-a-bsp-extension-for-downloading-a-table</a>

  • How to convert a HTML files into a text file using Java

    Hi guys...!
    I was wondering if there is a way to convert a HTML file into a text file using java programing language. Likewise I would also like to know if there is a way to convert any type of file (excel, power point, and word) into text using java.
    By the way, I really appreciated the help that you guys gave me on my previous topic on how to extract tests from a pdf file.
    Thank you....

    HTML files are already text files. What do you mean you want to convert them?
    I think if you search the web, you can find things for converting those MS Office files to text (or extracting text from them, as I assume you mean).

  • How to extract the Html content of a UI Map into a text file or html file?

    Hi,
    Is there any possibility in OUAF or Java or from the Database, to retrieve the Html Content of a given a UI Map ?
    If UI Map name is the input, then it should fetch the entire html portion of it into a text file. How to acheive this?
    This needs to be done programatically either by writing some Java code or some SQL at the DB level?
    Edited by: OATS Explorer on Dec 29, 2012 9:10 AM

    F1_MAP.HTML_DEFN would give the html contents and F1_SCHEMA.SCHEMA_DEFN would give you the UI Map's Schema.
    SELECT map.map_cd
      , map.html_defn
      , sch.schema_defn
    FROM f1_map map
      , f1_schema sch
    WHERE map.map_cd = sch.schema_name
    AND sch.schema_type_flg = 'F1MP'

Maybe you are looking for

  • Find Material Document with Movement type 103 for material document 105

    Hi experts, In PO History, I have three line items with movement type 103 (Blocked Stock) and one with movement type 105 (From blocked stock to unrestricted stock). I would like to know the material document with movement type 105 document that has t

  • Javascript error in Safari (sequel to roll-over button problem)

    Yesterday I started a thread on non-functioning roll-over buttons in Safari. In the mean time (with the help of iBod) I founs out that the problem has got something to do with JavaScript. The problem occurs in sites I built with FreewayPro 4.0.1 The

  • ORABPEL-09222

    We are getting an error message when loading more than 10 records through the BPEL process. Has anyone experienced this issue? I can't determine resolution and find out where I can see ORABPEL error messages like ORA- errors. Anyone have any suggesti

  • Change the owner of a project.

    I reinstalled my system. However, I changed my user name from jerry to home. Now I am unable to open any old iDVD projects. iDVD displays the message: Project locked by other user The project Belvin and Katrina # 1 is locked by the user jerry (user I

  • Linux or Ubuntu on an S10 Netbook

    I have a Lenovo S10.  It runs great, but in the spirit of gadgetry and curiosity, I would like to see what Linux or Ubuntu would be like on my S10. I would love to be able to boot it up from a USB drive. I have tried to read and understand the variou