Urgent!! Help me - Read formatted data from file

Hi,
I have a file which contains(line by line) :
[0.0577, 0.0769, 0.0385, 0.0, 0.0]
[0.0577, 0.1346, 0.0962, 0.0, 0.0]
[0.0192, 0.0, 0.0577, 0.1154, 0.0962]
How can i read the file line by line(exluded "[" and "]" symbols) and assign each line to an array?
Thanks

full code regarding readin/writing
import java.net.*;
import java.io.*;
import java.util.*;
     public class FtpWrite {
               static StringBuffer Data = new StringBuffer(20);
         public static void main(String[] args) throws Exception {
               int jobNumber = 10006;
               String dataOut = "Liam Charles Rangers";
               URL ftpUrl = new URL("ftp://username:[email protected]/dataOutput.txt");
                       URLConnection conn = ftpUrl.openConnection();
               conn.setDoOutput(true);
                       OutputStream out = conn.getOutputStream();
               PrintWriter writer = new PrintWriter(out);
                       System.out.println("Writing to ftp");
               writer.print(jobNumber);
               writer.print('\t');
               writer.print(dataOut);
               writer.print('\n');
                       writer.close();
               out.close();
               String dataIn;
               InputStream inFile = ftpUrl.openStream();
               BufferedReader in = new BufferedReader(new InputStreamReader(inFile));
               dataIn = in.readLine();
               System.out.println("The data is" + dataIn);
               in.close();
                 StringTokenizer parser = new StringTokenizer(dataIn);
                   while (parser.hasMoreTokens()) {
                         System.out.println(parser.countTokens());
                         processWord(parser.nextToken(),parser.countTokens());}
               public static void processWord(String token, int position){
               int jobNumber = 0;
               System.out.println("in process word token = " + token + " at position" + position );
               if (position == 3)
                    jobNumber = Integer.parseInt(token);
               jobNumber = jobNumber * 2;
               System.out.println(jobNumber);
               if((position <3) && (position>=0))
                    Data.append(token);
                    Data.append(' ');
               System.out.println("Data is " + Data);
}this code has just been completed with a bit of help. I gave it to you warts and all.
Jim

Similar Messages

  • How to Read specific data from file and do a calculation and display on the output

    FYI: Below is the function use for the writing:
    -OpenFile(use ASCII)
    -sprintf
    -WriteFile
    Example: Output from the doc file
    …EndTime: 09:34:48 program time: 0.567663 sec
    …EndTime: 09:36:48 program time: 0.666666 sec
    My objective is to read data 0.666666 (FYI: is last sentence of the file) to do some calculation. How can we read specific data(specific location) from file..
    Any advice or help?
    What is the function needed?

    I would consider counting line feeds and checking for end-of file to isolate the last line, which then can be read using fscanf...
    Have a look at getc...
    character = fgetc ( stream );
    if ( character == '\n' ) // new line
    if ( character == EOF ) // end-of-file

  • Read XML data from file

    Hello!
    I have data in an xml file which i want to read into my program. The problem is i do not want to parse the whole file at once, but in sequece, maybe in to or three sequences. In other words i want to parse the frist part of the file, and then the next sequence.
    Is this possible and how? I use a SAXParser right now, but it parses the whole file at once. Examles and refrences to java api is appreciated
    Best Regards
    Yoshi

    Ok!
    the problem is not to call the function several times, but that the function parse in SAXParser parses the whole xml file at once, so im not sure how a switch case loop is going to help me, maybe you could clarify a little.
    The data in the xml file contains history im going to read into the program, simulating progress. each root element contains a progress. So i want to read one element at a time everey time i call the parse function or a function containing the SAXParse function
    like this
    <datafile>
    <loggfile>
    <time>10:11</time>
    <data>12323></data>
    </loggfile>
    <loggfile>
    <time>10:12</time>
    <data>12424</data>
    </loggfile>
    </datafile>
    best regards
    Yoshi

  • I have a VI and an attched .txt data file. Now I want to read the data from the .txt file and display it as an array in the front panel. But the result is not right. Any help?

    I have a VI and an attched .txt data file. Now I want to read the data from the .txt file and display it as an array in the front panel. But the result is not right. Any help?
    Attachments:
    try2.txt ‏2 KB
    read_array.vi ‏21 KB

    The problem is in the delimiters in your text file. By default, Read From Spreadsheet File.vi expects a tab delimited file. You can specify a delimiter (like a space), but Read From Spreadsheet File.vi has a problem with repeated delimiters: if you specify a single space as a delimiter and Read From Spreadsheet File.vi finds two spaces back-to-back, it stops reading that line. Your file (as I got it from your earlier post) is delimited by 4 spaces.
    Here are some of your choices to fix your problem.
    1. Change the source file to a tab delimited file. Your VI will then run as is.
    2. Change the source file to be delimited by a single space (rather than 4), then wire a string constant containing one space to the delimiter input of Read From Spreadsheet File.vi.
    3. Wire a string constant containing 4 spaces to the delimiter input of Read From Spreadsheet File.vi. Then your text file will run as is.
    Depending on where your text file comes from (see more comments below), I'd vote for choice 1: a tab delimited text file. It's the most common text output of spreadsheet programs.
    Comments for choices 1 and 2: Where does the text file come from? Is it automatically generated or manually generated? Will it be generated multiple times or just once? If it's manually generated or generated just once, you can use any text editor to change 4 spaces to a tab or to a single space. Note: if you want to change it to a tab delimited file, you can't enter a tab directly into a box in the search & replace dialog of many programs like notepad, but you can do a cut and paste. Before you start your search and replace (just in the text window of the editor), press tab. A tab character will be entered. Press Shift-LeftArrow (not Backspace) to highlight the tab character. Press Ctrl-X to cut the tab character. Start your search and replace (Ctrl-H in notepad in Windows 2000). Click into the Find What box. Enter four spaces. Click into the Replace With box. Press Ctrl-V to paste the tab character. And another thing: older versions of notepad don't have search and replace. Use any editor or word processor that does.

  • Urgent help in reading data from oracle

    Hi All
    I was reading the data from an oracle database table through jdbc and storing them in an ArrayList, since there were around 1000 records and performing the action by iterating through the arrayList
    But now the record count has gone up to 200000, so i don't want to store them in the ArrayList rather process them one after the other so that i can save the memory of the ArrayList
    What are the best ways of achieving this, do i need to use some tools or anything, please let me know?
    Any help would be greatly appreciated.
    Thanks
    Diana

    Reading one record at a time from the database is very very very slow. I suggest keeping it in a large array. Memory is cheap. Read up on 'java -xmx' on how to increase the amount of memory available for java if you think you are running out of memory.
    Do you really need all fields in a record and all records?
    If still need to process all records, you can fetch a subset of records (say, 10000) and process them, then fetch another subset. Your sql may support fetching a subset but I dont recall the syntax.

  • Kinect Explorer WPF C# read depth data from the file and conversion to skeleton

    Hello,
    I am using Kinect sensor to do some research on biometrics. Since it is impossible to find people to collect some samples, I would like to use samples from the TUM - GAID database, where there exist Color View and Depth View (in .raw format) samples. Therefore,
    I need to read these samples from the file and do a batch processing, instead of performing real-time collecting of samples (where I can take automatically the Skeleton view using the Kinect SDK). So, I need help on
    1. Reading the data from the file (instead of activating the Kinect sensor) and give this data as an input for conversion to a skeleton
    2. Read the .raw files 
    Thank you very much
    Kind regards

    Hiya,
     I doubt this forum, C Sharp, will provide much help. You are asking about the Kinects system not C#
    language. However, you can try this link; http://kinectforwindows.codeplex.com/
    Hope this help. Thanks :)

  • How to read the data from excel file and store into the table?

    Hi All,
    I have table with BLOB datatype contains a excel file. I have to read that data from excel and store into one table with all the fields in excel.
    All the excel fields and my table columns are same.
    Can you share with me how can acheive this using LOB's?
    Thanks

    Hi OraSuirya,
    you can try with external tables .
    syntax as follows
    create table ext_table_csv (
    i Number,
    n Varchar2(20),
    m Varchar2(20)
    organization external (
    type oracle_loader
    default directory ext_dir
    access parameters (
    records delimited by newline
    fields terminated by ','
    missing field values are null
    location ('file.csv')
    reject limit unlimited;
    For this you need to create directory
    Directory Creation syntax:
    create or replace directory ext_dir as 'D:\oracle\user_dir\ext_dir';
    grant read, write on directory ext_dir to <User>;
    please paste the excel file in the particular directory .
    I hope this will help you.
    Please correct me if I am wrong anywhere .
    Thanks,
    Tippu.

  • Reading the data from excel file which is in application server.

    Hi,
    Iam trying to read the data from excel file which is in application server.
    I tried using the function module ALSM_EXCEL_TO_INTERNAL_TABLE. But it didn't work.
    I tried just reading using open data set and read data set it is giving junk characters.
    Please suggest me if you have any solution.
    Best Regards,
    Brahma Reddy

    Hi Narendra,
    Please see the below code I have written
    OPEN DATASET pa_sfile for INPUT in text mode ENCODING  DEFAULT MESSAGE wf_mess.
    CHECK sy-subrc = 0.
    DO.
    READ DATASET pa_sfile INTO wf_string.
    IF sy-subrc <> 0.
    EXIT.
    else.
    split wf_string at wl_# into wf_field1 wf_field2 wa_upload-field3
    wa_upload-field4 wa_upload-field5 wa_upload-field6 wa_upload-field7 wa_upload-field8
    wa_upload-field9 wa_upload-field10 wa_upload-field11 wa_upload-field12 wa_upload-field13
    wa_upload-field14 wa_upload-field15 wa_upload-field16 wa_upload-field17 wa_upload-field18
    wa_upload-field19 wa_upload-field20 wa_upload-field21 wa_upload-field22 wa_upload-field23
    wa_upload-field24 wa_upload-field25 wa_upload-field26 wa_upload-field27 wa_upload-field28
    wa_upload-field29 wa_upload-field30 wa_upload-field31 wa_upload-field32 wa_upload-field33
    wa_upload-field34 wa_upload-field35 wa_upload-field36 .
    wa_upload-field1 = wf_field1.
    wa_upload-field2 = wf_field2.
    append wa_upload to int_upload.
    clear wa_upload.
    ENDIF.
    ENDDO.
    CLOSE DATASET pa_sfile.
    Please note Iam using ECC5.0 and it is not allowing me to declare wl_# as x as in your code.
    Also if Iam using text mode I should use extension encoding etc.( Where as not in your case).
    Please suggest me any other way.
    Thanks for your help,
    Brahma Reddy

  • Need help with EXS24 "read velocity range from file name"

    I am trying to import 127 drum samples to a single key using the option shown here. The option says "Map to key dropped on and read velocity range from file name". I can find no documentation in the manuals on how to do this. What is the syntax required in the file name to make this work? I need to do several of these imports. The capability is cleary there, but I need help on how the file name should be formatted. My thanks to anyone who can help.

    Hi
    Not a direct answer to your question, but if you are doing a lot of sample mapping etc, you may want to check out Redmatica's KeyMap Pro or the simpler Keymap 1:
    http://www.redmatica.com
    CCT

  • Read in data from a file

    Hello,
    I am EXTREMELY new to java programming. I've read a book on learning java and I have no clue how to read in data from an input (text) file.
    I'd like to have the user enter a filename at the keyboard. The file will contain data for two fields separated by a blank. I want to read it into an array of a class of objects. Ex. 1 8
    3 8
    8 49
    The first number should go into array.fld1 and the second number should go in array.fld2.
    ex. cout <<< please enter your filename
    cin >>filename << endl;
    i:=0;
    while not eof(filename)
    read array.fld1;
    read array.fld2;
    i++;
    Can someone help me with this??

    Simple example
    try {
            BufferedReader in = new BufferedReader(new FileReader("FileName.txt"));
            String str;
            while ((str = in.readLine()) != null) {
                //do whatever whith str       
            in.close();
        } catch (IOException e) {
            //Handle Exception...

  • What is the 'quickest' way to read char data from a txt file

    Hello,
    What is the 'quickest' way to read character data from a txt file stored on the phone to be displayed into the screen?
    Regards

    To be even a bit more constructive...
    Since J2me does not have a BufferedInputStream, it will help to implement it yourself. It's much faster since you read large blocks at ones in stread of seperate chars.
    something line this lets you read lines very fast:
      while ( bytesread < filesize ) {
             length = configfile.read( buff, 0, buff.length );
             // append buffer to temp String
             if ( length < buff.length ) {
                byte[]  buf  = new byte[length];
                System.arraycopy( buff, 0, buf, 0, length );
                tmp.append( new String( buf ) );
             } else {
                tmp.append( new String( buff ) );
             // look in tmp string for \r\n
             idx1 = tmp.toString().indexOf( "\r\n" );
             while ( idx1 >= 0 ) {
                //if found, split into line and rest of tmp
                line = tmp.toString().substring( 0, idx1 );
             /// ... do with it whatever you want ... ////
                tmp = new StringBuffer( tmp.toString().substring( idx1 + 2 ) );
                idx1 = tmp.toString().indexOf( "\r\n" );
             bytesread += length;
          }

  • 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

  • Regarding reading the data from the files without using Stremas

    hai to all of u...
    here i have a problem where i have to read the data from the files without using any streams.
    please guide me how to do this one,if possible by giving with an example
    Thanks & Regard
    M.Ramakrishna

    Simply put, you can't.
    By why do you need to?

  • Populate a table reading the data from a TXT file

    how can I populate a table reading the data from a TXT file?
    thanks

    Hey Kevin!
    Using FORMS.TEXT_IO to bulk load data from a file strikes me as re-inventing the wheel. It is just about justifiable in a self-service environment, but I regard the EXTERNAL TABLE is a better solution for that situation as well.
    The same applies to UTL_FILE. I think the ability to read text with UTL_FILE is primarily intended for read file-based configuration or file manipulation/processing rather than data loading.
    Re-writing a text file into SQL statements is too much like hard work (even with an editor that supports macro definition and regular expressions) for no real benefit. You lose all the bulk load peformance you would get from SQL*Loader. But for QAD I'd probably let you off with it.
    You missed out one obvious alternative: using Java to turn the contents of an XML file into a CLOB and inserting it into a table which is read by a PL/SQL procedure that parses the XML records and insert the retrieved data into a table.
    Stay lucky, APC

  • How to read the data from a file in another computer with user name and password login

    How to read read the data from a file in anohter computer which need to login with user name and password?

    duplicate post:  http://forums.ni.com/t5/LabVIEW/log-on-the-other-computer-with-user-name-and-password/m-p/2061478
    duplicate post:  http://forums.ni.com/t5/LabVIEW/do-need-to-enter-the-user-name-and-password-when-TCP-ip/m-p/2061612
    duplicate post   http://forums.ni.com/t5/LabVIEW/log-on-the-other-computer-with-user-name-and-password/m-p/2060682

Maybe you are looking for

  • Can't get emails from yahoo account on iPhone 4S

    Recently I am not receiving emails from my yahoo aaccount The Internet connection is active and I can access other apps just fine is there a problem with the yahoo IMAP server?

  • What are the best storage devices for use with Time Machine?

    My backup and storage requirements are minimal but still important to me.  What storage devices do my Apple using Compatriots find the best for data storage.  I do think that the Time Machine is a more than adequate program for my needs but would be

  • NSM 3.0.4 Agent Not Starting

    Hi, I've just installed NSM 3.0.4 Agents (from the 3.0.4 iso) on OES11 (with all updates), and the agent is failing to start properly. Here's what nsmagentd.log says: 01 2012-07-09 16:57:44 3600 0 8001 1408 7f180acb5700 Initializing Logger, re-openin

  • Flex and the browser

    when I run a flex application, my favorites side bar disappears. When I go into my browser and turn on the favorites panel, it then covers my web page. Anyone know how to fix this? Sincerely Sammy.

  • IE 11 launches OK (Win 8.1 system), but gives "Internet Explorer has stopped working" message when clicking on any/all links.

    As best I can recall, this happened after updating an Adobe program - probably Flash, but not sure.  Has anyone else encountered this?  I have not yet tried system restore because I'm not sure that's the answer.  If I roll back to the pre-Adobe updat