How to read and parse a comma delimited file?  Help

Hi, does anyone know to read and parse a comma delimited file?
Should I use StreamTokenizer, StringTokenizer, or the oro RegEx packages?
What is the best?
I have a file that has several lines of data that is double-quoted and comma delimited like:
"asdfadsf", "asdfasdfasfd", "asdfasdfasdf", "asdfasdf"
"asdfadsf", "asdfasdfasfd", "asdfasdfasdf", "asdfasdf"
Any help would be greatly appreciated.
thanks,
Spack

import java.util.*;
import java.io.*;
public class ResourcePortalParser
    public ResourcePortalParser()
    public Vector tokenize() throws IOException
      File reportFile = new File("C:\\Together5.5\\myprojects\\untitled2\\accessFile.txt");
     Vector tokenVector = new Vector();
      StreamTokenizer tokenized = new StreamTokenizer(new FileReader(reportFile));
     tokenized.eolIsSignificant(true);
          while (tokenized.nextToken() != StreamTokenizer.TT_EOF)
               switch(tokenized.ttype)
                    case StreamTokenizer.TT_WORD :
                    System.out.println("Adding token - " + tokenized.sval);
                         tokenVector.addElement(tokenized.sval);
                         break;
          return tokenVector;
[\code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • How to read and parse a remote XML file with Java

    Hi.
    Using J2SE v1.4.2, I'd like to read and parse a remote file:
    http://foo.com/file.xml
    Is it possible with Java? I'd be extremely grateful if someone could provide me any webpage showing a very simple code.
    Thank you very much.

    How about the following?
         import java.io.InputStream;
         import java.net.URL;
         import javax.xml.parsers.DocumentBuilder;
         import javax.xml.parsers.DocumentBuilderFactory;
         import org.w3c.dom.Document;
         public static void main(String[] args) throws Exception {
              DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
              DocumentBuilder db = dbf.newDocumentBuilder();
              URL url = new URL("http://foo.com/file.xml");
              InputStream inputStream = url.openStream();
              Document document = db.parse(inputStream);
              inputStream.close();
         }-Blaise

  • How to read and write data from json file from windows phone7 app

    Hi
    I am developing wp7 app for the use of students my questions are
    How can i write a code to read and write the json/text file for the wp7.
    I am using windows 7 OS, VS 2010 Edition.
    This is my code below:
    xaml:
    <Grid>
                        <TextBlock Height="45" HorizontalAlignment="Left" Margin="7,18,0,550" Name="textBlock1" Text="Full
    Name: " />
                        <TextBox Width="350" Height="70" HorizontalAlignment="Left" Margin="108,1,0,0" Name="txtName"
    Text="Enter your full name" VerticalAlignment="Top" />
                        <TextBlock Height="45" HorizontalAlignment="Left" Margin="6,75,0,0" Name="textBlock2" Text="Contact
    No: " VerticalAlignment="Top" />
                        <TextBox Width="350" Height="70" HorizontalAlignment="Left" Margin="108,61,0,480" Name="txtContact"
    Text="Enter your contact number" MaxLength="10" />
                        <Button Content="Register" Height="72" HorizontalAlignment="Left" Margin="10,330,0,0" Name="btnRegister"
    VerticalAlignment="Top" Width="190" Click="btnRegister_Click" />
                    </Grid>
    xaml.cs:
    private void btnRegister_Click(object sender, RoutedEventArgs e)
                string name, contact;
                name = txtName.Text;
                contact = txtContact.Text;
                try
                    if (name != "" && contact != "")
                        string msg = name + " " + contact;
                        MessageBox.Show(msg);
                        Student stud = new Student
                            Name= name,
                            Contact = contact,
                        string jsonString = JsonConvert.SerializeObject(stud);
                        MessageBox.Show(jsonString);
                    else
                        MessageBox.Show("Input Proper Information", MessageBoxButton.OK);
                catch (Exception ex)
                    MessageBox.Show(ex.Message);
    I have download NewtonSoft.json version 5.0.8.
    So, I am able to convert input data into json format, but how can I able to write and read this data from a json/text file.
    How can I do?
    Thank you in adv and please, reply soon.

    We don't have many samples left for Windows Phone 7 + Azure, the closest one to what you want to do is probably:
    Using Local Storage with OData on Windows Phone To Reduce Network Bandwidth
    this sample uses the local database feature: 'LINQ to SQL', available to Windows Phone 7.1 and 8.0 Silverlight applications, instead of simple file storage but even if you choose to stick with simple file storage I believe you should be able to adapt the
    networking related portions of the sample to your particular application.
    Eric Fleck, Windows Store and Windows Phone Developer Support. If you would like to provide feedback or suggestions for future improvements to the Windows Phone SDK please go to http://wpdev.uservoice.com/ where you can post your suggestions and/or cast
    your votes for existing suggestions.

  • Import Format for Separte Debit and Credit Columns (comma delimited file)

    I have a file that is comma delimited with a sparate debit column and a separate credit column:
    Sample:
    Ent,Acct,description,Dr,Cr
    ,1000,test,100,
    ,110010,another test,,100
    My import format is this:
    Comma delimited
    Field Number Number of Fields Expression
    Entity 1 5 SGB_ABC
    Account 2 5
    Amount 5 5 Script=DRCRSplit_Comma_Del.uss
    I've tried writing the following script to pull the amount from the debit column into the credit column but it just skips the lines with no amount in field 5.
    'Declare Variables
    Dim Field4
    Dim Field5
    'Retrieve Data
    Field4 = DW.Utilities.fParseString(strRecord, 4, 4, ",")
    Field5 = DW.Utilities.fParseString(strRecord, 5, 5, ",")
    'If Field4 has a value then fld 5 is to equal fld 4.
    If IsNumeric(Field5) Then
    Field5 = Field5
    Else
    Field5 = Field4
    End If
    'Return Result into FDM
    SQFLD5 = Field5
    End Function
    Can anyone tell me what I am doing wrong?
    Thanks!

    I got it to work using this script:
    Function DRCR_Comma_Del(strField, strRecord)
    'Hyperion FDM DataPump Import Script:
    'Created By:     testuser
    'Date Created:     7/22/2009 9:31:15 AM
    'Purpose: If Amount is in the DR column move it to the CR amount column.
    Dim DR
    Dim CR
    DR = DW.Utilities.fParseString(strRecord, 5, 4, ",")
    CR = DW.Utilities.fParseString(strRecord, 5, 5, ",")
    If IsNumeric(DR) Then
    strField = DR
    Else
    strField = "-" & CR
    End If
    DRCR_Comma_Del = strField
    End Function

  • How to read and edit any microsoft office files in...

    Hi,
    Anybody know, how to open any microsoft office files (excel, powerpoint, word) in nokia nuron 5230. I would like to edit office files into phone using any mobile office application.
    Please let me know and share download link immediately.
    Thank you

    To be able to edit files you need to purchase an additional application.
    Quickoffice is the app you need and it's available here:
    http://www.quickoffice.com/quickoffice_symbian/
    It may also be available in the ovi store.

  • How to read and write in a binary file?

    Hi all,
    how can i search in a binary file for string and replace this string with another
    bin file ...test.bin
    search String "DE AD FA 01"
    regards
    gebi

    You need to install Google on your computer. That way, you can search for all the information on that algorithm available on the Internet.

  • Reading and writing to a text file from an Applet

    I'm a novice java programming with very little formal programming training. I've pieced together enough knowledge to do what I've wanted to do so far...
    However, I've been unable to figure out how to read and write to a text file from an Applet (I can do it from a normal java program just fine). Here is a simple example of what I'd like to do (you can also look at it on my website: www.stat.colostate.edu/~leach/test02/test02.html). I know that there is some problem with permission/security but I'm not smart enough to understand what the error messages are telling or understand the few books I have. If anyone can tell me how to get this applet to work, or direct me to some referrences that would help me out I'd really appreciate it.
    Thanks,
    Andy
    import java.applet.Applet;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.io.*;
    public class test02 extends Applet {
    public Button B_go;
    public GridBagConstraints c;
    public void init() {
    this.setLayout(new GridBagLayout());
    c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    B_go = new Button("GO");
    c.gridx=1; c.gridy=0; c.gridwidth=1; c.gridheight=1;
    c.weightx = c.weighty = 0.0;
    B_go.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    print_stuff();
    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    this.add(B_go,c);
    public static void print_stuff() {
    try{
    File f = new File("test02.txt");
    PrintWriter out = new PrintWriter(new FileWriter(f));
    out.print("This is test02.txt");
    out.close();
    }catch(IOException e){**/}
    }

    I have almost the exact same problem, and I am in the same situation as you are with respects to the language.
    I am simply trying to create a file and output some garbage to it but my applet always spits back a security violation. I've tried eliminating the restrictions on the applet runner I use but I still get the error.
    My method:
    debug = new Label() ;
    debug.setLocation( 20, 20 ) ;
    debug.setSize( 500, 15 ) ;
    add( debug ) ;
    // output
    try
         OutputStream file = new FileOutputStream( new File( "" + getCodeBase() + "output.txt" ) ) ;
         byte[] buffer = { 1, 2, 3, 4, 5 } ;
         file.write( buffer ) ;
         file.close() ;
    } catch( Exception e )
         debug.setText( e.toString() ) ;
         Can anyone tell why this isnt working?

  • Reading comma delimited files

    Hi,
    What are the FMs that I can use to read comma delimited files. Also, will it be able to run in the background?
    Thanks,
    RT

    Hi Rob
       As far as i know, we can not upload data from
    persentation server in background. For that the file
    needs to be placed in application server and use Open dataset command.
    Below is just an example to help you have a feel of the
    same.
    eg:
    type: begin of t_data,
            vbeln like vbak-vblen,
            posnr like vbap-posnr,
            matnr like vbap-matnr,
            menge like vbap-menge,
          end of t_data.
    data: it_data type standard table of t_data.
    data: wa_data type t_data.
    data: l_content(100) type c.
      open dataset p_file for output in text mode.
      if sy-subrc ne 0.
    *** error reading file.
      else.
        do.
          read dataset p_file into l_content.
          if sy-subrc ne 0.
             close dataset p_file.
             exit.
          else.
             split l_content at ',' into wa_data-vbeln
               wa_data-posnr wa_data-matnr wa_data-menge.
             append wa_data to it_data.        
          endif
        enddo.
      endif.
    Hope this helps you.
    Kind Regards
    Eswar

  • Read and parse XML

    Hi all,
    is there some procedure or function or whatever I can use to read and parse an XML file into Oracle?
    The XML contains 30+ Megs of data, which would represent data in 10+ tables if you would convert it into flat files.
    I know I can read the XML and save it line by line in a table, but I do not want to parse it myself. It would be cool if there was a tool or so that would read the dtd definition of the XML, then read the XML data, parse it and create temporary tables with the flat content of the xml (can you code object oriented with PL/SQL? this would even be cooler!).
    Does someone have an idea how to do that?
    Thanks,
    Steff

    Wow, I've never tried to parse an XML file quite that large
    before. Does it contain a bunch of encoded binary data, or does it
    have houndreds of thousands of xml-nodes?
    In any event, I do have one thought:
    Do you need absolutely everything in the file? If you only
    need access to a small portion of it, it would be worth your while
    to pull out only the "stuff" that you need before you parse it. You
    could use regular expressions to strip out things you don't need,
    or to pull out only the stuff you do need.
    The more you can minimize the "parse" effort the better off
    you'll be.
    Alternatively, if it's a file describing many "records" of
    the same type, it would be best if you could "chunk" the file and
    parse each record individually.

  • How to read and update the value of property file

    Hi,
    I am not able read the values from property file.
    Please tell me how to read and update the values from property file using Properties class
    This is my property file : - Config.properties its located in D:\newfolder
    Values
    SMTP = localhost
    Now i need to change the value of the SMTP
    New value :
    SMTP =10.60.1.9
    Pls Help me
    Thanks
    Merlin Rosina,

    Post a small (<1 page) example program that forum members can copy and run that demonstrates your problem.

  • How to read and write a string into a txt.file

    Hi, I am now using BEA Workshop for Weblogic Platform version10. I am using J2EE is my programming language. The problem I encounter is as the above title; how to read and write a string into a txt.file with a specific root directory? Do you have any sample codes to reference?
    I hope someone can answer my question as soon as possible
    Thank you very much.

    Accessing the file system directly from a web app is a bad idea for several reasons. See http://weblogs.java.net/blog/simongbrown/archive/2003/10/file_access_in.html for a great discussion of the topic.
    On Weblogic there seems to be two ways to access files. First, use a File T3 connector from the console. Second, use java.net.URL with the file: protocol. The T3File object has been deprecated and suggests:
    Deprecated in WebLogic Server 6.1. Use java.net.URL.openConnection() instead.
    Edited by: m0smith on Mar 12, 2008 5:18 PM

  • How to read and write a data from extrenal file

    Hi..
    How to read and write a data from extrenal file using Pl/sql?
    Is it possible from Dyanamic Sql or any other way?
    Reagards
    Raju

    utl_file
    Re: How to Create text(dat) file.
    Message was edited by:
    jeneesh

  • How to Read and Write .XML datas   (HELP Plz...)

    hai everybody
    how to read and write xml datas... plz give clean and simple example..
    bcoz me want to produce such type of module...
    if any one help me .. thats the only way me laid in software ladder
    plz....
    thank u in advance

    thank u for giving idiot..
    but before posting i search in google also..
    but i cant get what me expect..
    thus i posted...
    then who is ................?
    sorry javacoder01
    // plz help me
    Message was edited by:
    drvijayy2k2

  • How to read and upload microsoft word file into database using forms9i

    Hi,
    How to read and upload microsoft word file into oracle database using forms9i. I appretiate if anyone can send me example or atleast a sujjetion.
    Thanks in advance
    Mahesh Ragineni

    The webutil package includes the ability up upload from the client to the database. See otn.oracle.com/products/forms and click on webutil for more details.
    Regards
    Grant Ronald
    Forms Product Management

  • How to read and write on ntfs partitions??

    Hello everyone, thanks for viewing my post.  I want to know how to read and write on ntfs partitions under sata hd on my arch64 system.  I'm using kde as my de and dolphin does sees it but can't access it anyway.  I didn't had problem so far on mounting usb drives it just automounts maybe because it is a fat partition not a ntfs?  Please I need your help...Thanks in advance:)

    You will most likely need to rework your fstab.  The one from my desktop is shown below. If you want regular users to be able to access the partition, then you will need to change the gid option as I have done. Although you could create a group just for people you want to have access.
    You will need to know the device that your windows partition is held on of course. In my case it is my first hard disk, first partition, hence /dev/sda1.
    # /etc/fstab: static file system information
    # <file system> <dir> <type> <options> <dump> <pass>
    none /dev/pts devpts defaults 0 0
    none /dev/shm tmpfs defaults 0 0
    /dev/cdrom /media/cdrom auto ro,user,noauto,unhide 0 0
    /dev/dvd /media/dvd auto ro,user,noauto,unhide 0 0
    /dev/mapper/nvidia_fbgfhehd1 /boot ext2 defaults 0 1
    /dev/mapper/nvidia_fbgfhehd2 / reiserfs defaults 0 1
    /dev/mapper/nvidia_fbgfhehd3 /var reiserfs defaults 0 1
    /dev/mapper/nvidia_fbgfhehd5 /opt reiserfs defaults 0 1
    /dev/mapper/nvidia_fbgfhehd6 swap swap defaults 0 0
    /dev/mapper/nvidia_fbgfhehd7 /home reiserfs defaults 0 1
    /dev/sdd1 /mnt/andromeda vfat defaults 0 0
    /dev/sda1 /mnt/windows ntfs-3g defaults,user,gid=users 0 0
    My XP partition is set to mount automatically, as I regularly interchange documents between the OS's.
    Hope that helps.

Maybe you are looking for

  • Error while creating a material using Bapi_material_savedata

    Hi, there is an error encountered while creating a material using BAPI_MATERIAL_SAVEDATA.. The Error description is " Material description is not transfered " even after supplying the Material description and other mandatory field information like in

  • Residual item clearing using FM/BAPI

    Hi all, Below is my requirement. When invoice is created from VF01 the invoice has to automatically cleared against the prepayment document. If the invoice amount is less than the prepayment amount then we need to create a residual document for the d

  • Font Size with LV 2014

       I'm still puzzled by why LV has a default 15pt font on some newer installs and newer OS's.  I don't know what exactly the condition for this is.  Is it the LabVIEW version, the OS version, some graphical setting within the OS?    I had pretty much

  • Prepayment option

    Hello together, we need a "prepayment" and "cash and carry" payment option in bc? is there a way to do that with bc features? Would be great if anybody have an idea. cheers!

  • How to configure servlets in Oracle AS 10g

    Hi, I am Ashish from Mumbai. I am using Oracle DB and Oracle Application Server on same machine. I have deployed a Java Web application on the server using the web administration of server. It contains several servlets. Whenever I tried to use servle