read a file line-by-line ascii

I'm new with CVI, and I need to read a file ascii with several lines in the following format:

at_test_2_to_13 = 0.861000
at_testabcd_9_to_21 = 0.712000
at_abdgx_5_to_8 = 0.892000

Here is the code to write to the ascii file:

sprintf (ctResult, "% s=%f\n", TestName1, result1);
WriteFile (fileHdl, ctResult, StringLength (ctResult));

A moment later, I need to read the text file, find the name of test (for example, "at_testabcd_9_to_21") and record the value after the sign '=' (in this case 0.712000). The number of lines in the text file is not fixed.

I write data to the file without any problem, but I'm right in the reading of the data.

I'd appreciate any help in writing this code in CVI.

Thanks in advance

I thank very you much for all the help!

The INI file is the way to go on this case.

With the help of a colleague, I used the following to create and read from the ini:

DllExport __declspec(dllexport) __stdcall #define

int DllExport WriteToIniFile(char *Section,char *Key,char *StringVal,char *IniFileName)
{int Err = 0;
WritePrivateProfileString (Section, Key, StringVal, IniFileName);
Return (Err);
}
int DllExport ReadFromIniFile(char *Section,char *Key,char *ReadStr,char *IniFileName)
{int Err = 0;
DWORD CharCount.
CharCount = GetPrivateProfileString (Section, Key,"", ReadStr, sizeof (ReadStr), IniFileName ");
Return (Err);
}

Also thank you very much for all the help with the code C. I have been using VB most of my career, and since I am labwindows user now I need to catch up on my C!

Thank you once again

Tags: NI Software

Similar Questions

  • Read text Vi, of reading the additional lines

    I use a read text file line by line

    If I have 22 average lines, there are 23... I m facing problem here

    Please help me

    If you need a loop (I will prefer loop For), to read all the files (1 per 1) and reading of text file placed in the loop, read all the lines of each file only once... So let's say you have 10 files to read, because the loop runs 10 times and so will read from text file function.

    Edited: added, it seems that you already have a loop For (outermost)... I was mentioning that you can remove the while loop (inner loop shown in your picture, also I had circled it in red)... For loop will be ongoing to be staying.

  • specific line of reading a file

    is there a VI to read a specific line of a csv file. I have a csv file that is too large to load and unfortunately whlle spreadsheet file reading, is useful in some cases, you can not specify which row to start from, it can begin in the first line.

    I saw a lot of other suggestions on recent discussions, but none of them are a convincing solution.

    It is absolutely wrong to say that reading worksheet cannot begin until the first line. There is an entry called 'start reading offset '.

    Reading in blocks is to use this with a shift register. For example, if you wanted to read 1000 rows at a time, you must specify that the number of lines to read and the release of 'brand after reading' would be connected to a shift to the right and left, register wired to the "start of playback. The shift register may be initialized to 0.

  • Reading a file of OS with size greater than 32 KB line

    Hi experts,


    I have a PL/SQL function that reads a file generated by a product of part 3 - Windows product displays a single line of text. I intend to read the file into pieces of 32K, do some string manipulation and copy into a CLOB that I spend for further processing. He eventually embeded in a CLOB containing WordML and output to a file. The CLOB is not saved in the database.

    I use UTL_FILE for work, FOPEN and GET_LINE. However, this operation fails for files with more than 32K characters in the line. Is there another way I can read the file?

    Obviously I can do processing on the file outside the Oracle to divide it into smaller lines, however, this will affect performance.

    Kind regards
    Arun

    Hello Arun,

    Welcome to the forum.

    You can read a file directly in a CLOB

    CREATE OR REPLACE
    FUNCTION getFile
        (
         p_directory     IN all_directories.directory_name%TYPE
        ,p_filename      IN VARCHAR2
        )
        RETURN CLOB
    IS
        v_bfile             BFILE;
        v_file              CLOB;
        v_error_out         INTEGER;
        dest_offset         INTEGER := 1;
        src_offset          INTEGER := 1;
        bfile_csid          INTEGER := 0;
        lang_context        INTEGER := dbms_lob.default_lang_ctx;
        e_inconvertibleChar EXCEPTION;
    BEGIN
    
        v_bfile := bfilename( p_directory,p_filename);
    
        dbms_lob.fileOpen( v_bfile, dbms_lob.file_readonly );
    
        dbms_lob.createTemporary(v_file, TRUE);
    
        dbms_lob.loadClobFromfile(
             v_file
            ,v_bfile
            ,dbms_lob.lobMaxSize
            ,dest_offset
            ,src_offset
            ,bfile_csid
            ,lang_context
            ,v_error_out
            );
        dbms_lob.fileClose(v_bfile) ;
    
        IF v_error_out = dbms_lob.warn_inconvertible_char THEN
            RAISE e_inconvertibleChar;
        ELSIF v_error_out != 0 THEN
            RAISE_APPLICATION_ERROR(-20001,'Unknown errornumber '||v_error_out,TRUE);
        END IF;
    
        RETURN v_file;
    
    EXCEPTION
        WHEN e_inconvertibleChar THEN
            RAISE_APPLICATION_ERROR(-20001,'Inconvertible charset',TRUE);
    END getFile;
    

    Concerning
    Marcus

    Published by: Marwim on 10.07.2012 17:24

  • Syntax to detect the line feed or newline read text file?

    I have a SQR (aka Hyperion Production Reporting) program that treats a comma-delimited text file.

    Sometimes one of the fields contains carriage returns and line breaks, that's not groovy, as is the record delimiter.
    The program currently handles this situation by disgarding records that do not contain the specified number of fields.

    I would like to scan the file before treatment, pickling, transport and line breaks, returns when they are integrated in a record.
    I have problems with the syntax required to recognize these characters, however.

    The program reads the file in a string (for example read 1 $record_buffer: #len).
    then it executes a while loop that examines the $record_buffer string one character at a time.

    I tried a direct comparison: If $char = Chr (10) or $char = Chr (13)
    I tried to assign a chr() value to a variable before the comparison: Let $LF = chr (1)... If $char = $LF
    I tried using code before the comparison: encode '< 10 >' in $LF... If $char = $LF...

    Could someone help me with this?

    Thank you!
    Laura

    Here's the syntax that works:

    #ifdef EBCDIC
    encode "<13><37>" in $hr
    #else
    encode "<13><10>" in $hr
    #end - if

    (replace the return with the null character)

    LET $descrlong = translate (& descrlong Chr (13), ")

    OR try the following code:

    !**********************

    ! Retrieve a line *.

    !**********************

    ! This local function / procedure will look for tank 13 which is a line terminator. The position where is returned

    ! to the routine.

    ! Parameters: $strToRead = this string that contains the formula is parsed to find the tank 13 (end of line) identifier

    ! : #startPos = the position where we need to find the identifier EOL

    ! : #PositionFound - this by the reference variable returns the position where the EOL.

    !

    BEGIN-process Get-Line($strToRead,#startPos,:#PositionFound)

    Let #PositionFound = instr ($strToRead, chr (13), #startPos)

    Proceedings

  • I have 10 items.  I'm trying to update camera raw plug so it will read the first lines of a 7dmarkii shot. I can't find where to put them to update to the latest version of 8.7.  If someone could please point me in the right direction.  Thank you very muc

    I have 10 items.  I'm trying to update camera raw plug so it will read the first lines of a 7dmarkii shot. I can't find where to put them to update to the latest version of 8.7.  If someone could please point me in the right direction, I would really appreciate it!

    Normally, I shoot with the 7dmarki and have never had any problems.  After troubleshooting my error message 'cannot open IMG1111 because it's the wrong file type', only the options have been updated plugin raw from the camera, to buy the latest version or uninstall and reinstall.  First train to the plugin to update because it was a leased device.  Thanks again!

    Thanks MichelBParis!  I didn't see where he said to 12 items.  I downloaded the free DNG Converter last night and not had much luck.  It is not recognizing that I have all files in the folder at all.  Don't know what I'm doing wrong!

  • Zoom function disabled so can't enlarge the text on the main screen hard to read the subject lines of e-mail messages, looks like 6 pt type size, activated after the opening of e-mail.

    The text size is so low in the views of folders for primary e-mail that it is very difficult to read the subject lines of emails. I think I remember that earlier versions 'Zoom' has been activated and you could adjust the size. Looks like that the size is set at approximately 6 pt type. Must be at least 12 points. Thanks, C Sanders

    I thin you will find that it is this add-on you are looking for https://addons.mozilla.org/en-us/thunderbird/addon/theme-font-size-changer/

    Installation instructions http://chrisramsden.vfast.co.uk/3_How_to_install_Add-ons_in_Thunderbird.html

  • Read a PFI line in LV2009?

    Is there a screw (2009) which will allow you to access the value on the PFI lines live?  See what they are?  The wired customer lines PFI to read a logic level under certain conditions.

    clint100,

    I think that there is some mixup nomenclature, let me give you my point of view to see if that clears up things.

    While you can't 'read' the PFI line, it can use an event on this line to trigger or sample (see the link a few posts to the top) to do something, you might be "expecting".  I also see why you want to read or query the line to control the flow of your code, if you were on a microcontroller or FPGA you would be wrong.  The traditional DAQ or DAQmx driver is more abstract than that and will want to take this entry as a trigger, or a sample of clock.

    That being said, there is a bagillion to the examples in the example finder to help you configure that.  Otherwise, I may be completely wrong interpret the sentence you put in your message, anyway, good luck!

  • Toolbar is a single-file line

    Photoshop elements editor 12 advanced, Macbook Air OS x El Captain running.

    All my tools are now in single file line, and I can't understand how to fix it.  I tried to rummage in the settings, but nothing works.  It happened when I missed a few times when you try to select the Brush tool.  I tried to click several times on the toolbar to see if she reversed, but not luck.

    Hello

    In photoshop elements 12 go to window > reset panels and see if it works.

  • How can I Mindprint my CS5 to read the FIRST lines of my Panosonic DMC FZ200 new?

    My Adobe CS5 cannot read RAW files I tried pp inside of two new cameras. What good is to have a software that is supposed to be able to read the RAW files when it will not be for new material. Surely, it should be able to adapt to the new cameras as they arise. Today I tried to download a sample RAW file of a review of the new Canon 5 d Mark iii online. He begins to open up in CS5 but then says he can't read the RAW files from this camera either. How to change that in my Photoshop CS5. I havn't in 10 items tried yet. He will do the same thing and will it change the settings it too? Can I post process my Canon XSi RAW and XTi files without any problem.

    What good is to have a software that is supposed to be able to read the RAW files when it will not be for new material. Surely, it should be able to adapt to the new cameras as they arise.

    What says Christmas.

    FYI, Adobe supports constantly new cameras with new versions of Camera Raw.

    http://helpx.Adobe.com/Creative-Suite/KB/camera-raw-plug-supported-cameras.html

    But you need to upgrade your version of Photoshop in order to run the latest versions of Camera Raw for reading released on the latest models of camera Raw files. Or join the Cloud and you can keep your current software at any time through your membership.

    http://helpx.Adobe.com/x-productkb/global/camera-raw-compatible-applications.html

    Or run the free Adobe DNG converter, convert all the Raw files to DNG, and then edit the DNG in Photoshop

    http://www.Adobe.com/products/Photoshop/extend.displayTab2.html

    Winner: http://www.adobe.com/support/downloads/detail.jsp?ftpID=5519

    Mac: http://www.adobe.com/support/downloads/detail.jsp?ftpID=5518

    DNG conversion requires additional steps - but it's free.

  • Read/write file in Unicode (UTF-16)

    Hi, I have a problem to write a file in Unicode (UTF-16)

    I have to read a file with LabView, change some settings and write the new data in the same file. The file uses Unicode UTF-16.

    I downloaded a few library here: https://decibel.ni.com/content/docs/DOC-10153

    I can read the file, convert the data to ASCII/UNI/UNI and then write the file. But when I open the new file with an editor like Notepad ++ there is some unexpected characters at the end of the line.

    Even read the file and write exactly the same doesn' data not work.

    I've attached an example.

    Thanks for you the kind of support.

    Right click on your functions read and write text files.  There is an option to "Convert End Of Line".  Who turned off the two functions.

    As a side not, you need not close file functions.  The functions Read and Write Text File will close the file that reference output file is not connected.

  • How to read two files (one updates every second, the other is constant) simoltaneously

    Dear all,

    I'd appreciate if someone help me.

    I want to read two files, one is the temperature that updates every second, and the other is energy hysteresis that has specific lines and is constant.

    I had a program in the discussion forum to read a file as it is updated. I checked this program in my case and it works.

    Then I added playback file hysteresis energy to the existing file. But while I run the program, the energy hysteresis file is read with all the lines.

    But the goal is that every time the updates of the temperature, I need to read a line of the file hysteresis energy.

    in this way every second, so, I have a new temperature data and a row of the other file.

    I tried to use 'for loop' inside the program, but it did not work, because the temperature reading will stop until that end of the loop.

    I joined the program.

    Could someone help me how read only a row of hysteresis energy file every time that the temperature updated?

    IS that what you wanted to achieve?

  • Read the file

    I want to read all the data in a file line by line. I'll write data to tables and plot the data later. Once all the data is read in I want to wait a minute and read any new information that has been added to the file. I expect only the file to be updated once per minute, with a single line of data. The problem that I got, as soon as I close the file and then open to replay it starts at the beginning, that I don't want. Is there a way to write privileges to another program for the data file unless it is closed by labview? In this way, I hope reading each new line without since the beginning. Right now I use the function text file reading which is not an input file location. Is it possible to use it or I have to use a different function. I have attached my vi. Thanks in advance for any help.

    ssmith

    ssmith490D wrote:

    . Is there a way to write privileges to another program for the data file unless it is closed by labview?

    Not that I know of.

    What you can do is to store the position of file once you finish last read and store in a shift register.  When you reopen the file, use set the file Position to set the file position and start reading from there.

  • Problem with reading Xlsx file string.

    Hello! I'm reading of digital data and string a xlsx file and tries to display its content in a word file. I tried to convert a .lvm file too. Use the "Reading worksheet" tool, I get random characters as output. On tool using 'Read the file of measure', I get an error saying "error 100 occurred reading file measure-> Untitled 1". What should I do? In the end, I need display output, line by line, in Microsoft Word format. I'm so lost. Help, please.

    Reading worksheet cannot read a xls file. Reading worksheet can read text files. In general, comma or a tab separated. To read a xls file, you must use ActiveX, such as the use of the report generation tool.

  • You want to read binary files in some parts of the 500th row in the 5 000th row.

    I have files of 200 MB of 1000561 lines binary data and 32 columns when I read the file and sequentially conspire full memory of the generated message.

    Now, I want to read the file in pieces as the 500th row 5,000th row with all the columns and it draw in the graph.

    I tried to develop logic using functions file advanced set file position and the binary file reading block, but still not get the sollution.

    Please, help me to solve this problem.

    Thanks in advance...

    Hi ospl,.

    To read a specific part of the binary, I suggest to set the file position where you want to read the data and specify how many blocks you must read binary file for reading binary file.VI

    for example, if you write table 2D binary file, and then mention you data type this 2D chart and make your account (5000-500). Then together, you produce position. If you have 32 DBL data type and column then it is 256 to the second row and 256 * 500 for line 501th. Use this number as input into your position.vi file get.

    I hope you find you way through this.

Maybe you are looking for

  • Crash suddenly satellite 404!

    My satellite 404 sometimes stops during intensive tasks (such as scanning of the hard drive for virussses etc..). When this happens, it stops immediately, without any warning. Someone knows how to fix this? Thank you

  • HDD upgrade for Satellite Pro M70

    Is anyone know the upgrades available to change the standard 60GB hard drive in the Satellite Pro M70 (PSM76E-00100KEN) with something bigger. The Toshiba Options site shows only optionally available external hard drives, but noticed that the newer m

  • Activate my I pad

    I need to activate my I pad and do not know the ID apple allows you to configure the IDs.

  • announce incoming calls on bluetooth?

    i've got att iphone6.  friends have iphone6 on verizon.  when their phones ring * Bluetooth *, the incoming phone number is announced (with a ring tone). It is a feature of verizon or can it be installed on any iphone 6?  or a hidden feature of at &

  • Can I replace the nVidia GT 740 M GPU on my Z510?

    Can I replace the nVidia GT 740 M GPU on my Z510? I don't want loose my laptop only for verification and then violate the warranity. Thanks in advance