How to ignore comments in a CSV file

Here's what my CSV file looks like
#Comment 1
#Comment 2
#Comment 3
US,20080101,20080526,20080901
I'm reading in this file. How can I ignore all the comment lines? I can code it to ignore all lines begin with # but I thought this feature is built into the language already. Maybe I'm using a wrong class. I'm using Scanner right now and it reads in all the comments as well.
Scanner sc = new Scanner(new File("test.txt")).useDelimiter(",");
while (sc.hasNext()) {
System.err.println(sc.next());
}

It's not built into the language. Your best bet is probably to put the CSV-Reading logic into its own class.
Or find one of the thousands of classes that already implement such a thing.

Similar Messages

  • How to load the data from .csv file to oracle table???

    Hi,
    I am using oracle 10g , plsql developer. Can anyone help me in how to load the data from .csv file to oracle table. The table is already created with the required columns. The .csv file is having about 10lakh records. Is it possible to load 10lakh records. can any one please tell me how to proceed.
    Thanks in advance

    981145 wrote:
    Can you tell more about sql * loader??? how to know that utility is available for me or not??? I am using oracle 10g database and plsql developer???SQL*Loader is part of the Oracle client. If you have a developer installation you should normally have it on your client.
    the command is
    sqlldrType it and see if you have it installed.
    Have a look also at the FAQ link posted by Marwin.
    There are plenty of examples also on the web.
    Regards.
    Al

  • How can we a validate a CSV file in SSIS and log the error details in another CSV File by using Sript Task.

    How can we a  validate a CSV file in SSIS and log the error details in another CSV File by using Sript Task.

    Please see:
    http://www.bidn.com/blogs/DevinKnight/ssis/76/does-file-exist-check-in-ssis
    http://social.msdn.microsoft.com/Forums/en-US/01ce7e4b-5a33-454b-8056-d48341da5eb2/vb-script-to-write-variables-to-text-file

  • How to ignore 1st row form the file(csv) sender CC

    Hi,
    I have a CSV File (File sender) that I need to load with PI.I want to Ignore 1st row from the file.
    For example the File contains 10 rows  but PI  need to read  the data from 2nd row.
    because in the 1st row contains header data like name, number, mobile, address, etc., I don't want to read this 1st row. I want to read only the data which starts from the 2nd row.
    can you pls tell me the ignore command File Receiver CC
    I am using these commands.
    Record structure: item,*
    item.fieldSeparator: ,
    item.endSeparator : 'nl'
    item.fieldNames:   Name, Number, Address, Mobile
    Thanks in Adv
    Vankadoath

    Hi Vankadoath,
    In your content conversion use the field document offset which ignores the number of lines to be ignored.
    for example if you provide the value as "1" for document offset it will ignore the first line in your file.
    (Under Document Offset, specify the number of lines that are to be ignored at the beginning of the document.
    This enables you to skip comment lines or column names during processing.
    Regards,
    Naveen.

  • How to solve extra commas in CSV files in FCC..!!

    Hi,
    I have the CSV file with comma(,) separator which has around 50 fields. Among them there were some description fields which has comma (ex: karan,kumar) which has to come as a single field and comes as 51 fields instead of 50.
    Due to this, im facing problem at File content conversion and it is failing with error " ERROR converting document line no. 8534 according to structure 'Header':java.lang.Exception: ERROR in configuration / structure 'Header.': More elements in file csv structure than field names specified!
    We have around 10 fields which comes in this way.Any idea how to solve this issue?
    Thanks
    Deepthi.

    Hello Deepthi,
                 The option here is use fieldFixedLengths instead of fieldSeparator. By this way evethough you have more fields in file than given filednames, it will not trigger any error. (But this one will still keep the commas which you might not need in the xml structure, though you can replace these in mapping anyway this is one solution )
    enclosureSign option you can try, but you need do include the delimeter in you file structure, which is again a troublesum.
    eg:- field1, | karan,kumar|,fieldn
    In case you are familier with Adapter Module you can do it  easily, but its a final option as far i am concern.
    Regards,
    Prasanna

  • How to export data to multiple csv files?

    Hey Scripting Guys,
    As stated by the name I'm a novice at scripting.  Typically I'm able to resolve most of my scripting challenges by reading through your site or scouring the internet.  This challenge I haven't been able to resolve.  Please help!!
    I'm running a script (posted below) to grab data and export it to a csv file.  My challenge is that I want to run the script daily via task manager and have it create a new csv file either daily or weekly.  I'm having trouble with the scripting
    creating a new csv file.  How do I resolve this?  
    It would be beneficial to append the date to a standard file name, ex. c:\exportedcsv7-11-2014.csv; the next day it would be c:\exportedcsv7-12-2014.csv; and so on.
    Thank you in advance to any assistance.
    Respectfully,
    ScriptingNovice
    Get-Datastore -Name "*DS*" | Sort $_.name | Get-View | Select -ExpandProperty Summary | `
    Select Name,
    @{N=”FreeSpaceGB”;E={[Math]::Round($_.FreeSpace/1GB,2)}},
    @{N=”CapacityGB”; E={[Math]::Round($_.Capacity/1GB,2)}},
    @{N=”UncommittedGB”; E={[Math]::Round($_.Uncommitted/1GB,2)}},
    @{N=”ProvisionedGB”;E={[Math]::Round(($_.Capacity – $_.FreeSpace + $_.Uncommitted)/1GB,2)}},
    @{N=”Over-Provisioned-DS”;E={([Math]::Round($_.Capacity/1GB,2)) – ([Math]::Round(($_.Capacity – $_.FreeSpace + $_.Uncommitted)/1GB,2))}}| `
    select Name,CapacityGB,FreespaceGB,ProvisionedGB,UncommittedGB,Over-Provisioned-DS | export-csv -notype c:\vmds.csv

    Thank you for the information and the tip.  I took your advice and did some research on Strings, something that I do have trouble grasping.  I'm familiar with variables already and feel comfortable using them.  I also need to study .Net which
    I totally don't understand. 
    Since I appreciate your advice and guidance I'd like to know if I'm on the correct track.  Please look at my breakdown to see if I'm explaining it correctly.
    $d=Get-Date
    Here a variable is being created using the Get-Date cmdlet, if we execute $d the date will appear
    $d.ToString('dd-MM-yyyy')
    This converts the date into the format dd-MM-yyyy.
    I took the information and tips you provided then came up with this after reading about strings.
    export-csv -notype "c:\folder\vmds_$($d.ToString('MM-dd-yyyy')).csv"
    The double quotes evaluate the variables.  The single quotes do not evaluate anything they just show what's inside of them (a.k.a. literal string). The $() evaluate the expression in ('MM-dd-yyyy') before writing it.
    You are correct I definitely need to strengthen the foundation of my basics.  Thank you for the direction and advice.

  • How to display data from local csv files (in a folder on my desktop) in my flex air application using a datagrid?

    Hello, I am very new to flex and don't have a programming background. I am trying to create an air app with flex that looks at a folder on the users desktop where csv files will be dropped by the user. In the air app the user will be able to browse and look for a specific csv file in a list container, once selected the information from that file should be displayed in a datagrid bellow. Finally i will be using Alive PDF to create a pdf from the information in this datagrid laid out in an invoice format. Bellow is the source code for my app as a visual refference, it only has the containers with no working code. I have also attached a sample csv file so you can see what i am working with. Can this be done? How do i do this? Please help.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="794" height="666">
        <mx:Label x="280" y="19" text="1. Select Purchase Order"/>
        <mx:List y="45" width="232" horizontalCenter="0"></mx:List>
        <mx:Label x="158" y="242" text="2. Verify Information"/>
        <mx:DataGrid y="268" height="297" horizontalCenter="0" width="476">
            <mx:columns>
                <mx:DataGridColumn headerText="Column 1" dataField="col1"/>
                <mx:DataGridColumn headerText="Column 2" dataField="col2"/>
                <mx:DataGridColumn headerText="Column 3" dataField="col3"/>
            </mx:columns>
        </mx:DataGrid>
        <mx:Label x="355" y="606" text="3. Generated PDF"/>
        <mx:Button label="Click Here" horizontalCenter="0" verticalCenter="311"/>
    </mx:WindowedApplication>

    Open the file, parse it, populate an ArrayCollection or XMLListCollection, and make the collection the DataGrid dataProvider:
    http://livedocs.adobe.com/flex/3/html/help.html?content=Filesystem_08.html
    http://livedocs.adobe.com/flex/3/html/help.html?content=12_Using_Regular_Expressions_01.ht ml
    http://livedocs.adobe.com/flex/3/html/help.html?content=dpcontrols_6.html
    http://livedocs.adobe.com/flex/3/langref/mx/collections/ArrayCollection.html
    http://livedocs.adobe.com/flex/3/langref/mx/collections/XMLListCollection.html
    If this post answered your question or helped, please mark it as such.

  • How to import old iPhone SMS.CSV file into new iPhone?

    Hey everyone,
    So I've spent a couple days on this as I just upgraded to the iPhone5S from my 4S.  Long story short, my backup restore didn't work after multiple tries (gave me the file is corrupt or not compatible with the iPhone error). 
    I tried:
    -reinstalling itunes
    -updating itunes
    -combining the 5S backup with the old 4S backup
    -tinyumbrella
    and a few of other things as I've forgot now.
    The most important things I needed was the contact list and SMS history.  I've got the contact list from extracting is successfully from the iTunes backup folder and using iCloud, but cannot figure out how to import the SMS.CSV file into my iPhone5S.
    Any suggestions on how I can get my SMS messages from my iPhone4s into my 5S?
    If anyone has any other suggestions on getting my Backup Restore to work that would be awesome too!
    Thanks!

    A word on SMS text messages. It is pracitcally impossible to import an SMS text-messages file to a new iPhone and have the Messages app on the new device read the messages.
    You can transfer, however contacts and other individual data (such as calendars and notes) from one iphone to the next. I had my old Nokia which whose contacts I exported to a CSV file. I then imported the file to my iphone which converted the file into multiple contacts in the Contacts app on the iphone. You can use a contact management app such as this one in order to import the contact file to the new iPhone.

  • How to create a header in csv file

    I´m still newbie in Labview, I just learnt it this week..
    I want to make a data translation for temperature sensor..
    I´m having trouble to create a header in csv file,can anybody help me ?
    I also attach my csv file, what I wanted to make is like this :
    dt ( ms )
    channel 0
    channel 1
    channel 2
    0,1
    1
    2
    3
    0,2
    4
    5
    6
    0,3
    7
    8
    9
    0,4
    10
    11
    12
     I also want to know how to make the time count from 0 not from the real time..
    Solved!
    Go to Solution.
    Attachments:
    my block diagram.jpg ‏266 KB
    my csv file.jpg ‏508 KB

    I already solve the problem, It´s quite confusing, I must use ; instead of \t at the delimiter.
    I have another question to ask :
    - When I start the program,can I make the dt(ms) count from 0 ? What I can do is using the Format/Date time string, I don´t want the time count based on the real time.
    This is what I made
    dt(ms)
    Ch0
    10:04:2012  13:12:06,871
    24,139404
    10:04:2012   13:12:08,924
    23,773193
    10:04:2012   13:12:08,925
    23,132324
    10:04:2012   13:12:08,926
    22,918701
    What I want is like this :
    dt(ms)
    Ch0
    0
    24,139404
    0,01
    23,773193
    0,02
    23,132324
    0,03
    22,918701
    Thx for the helps..
    Regards
    Citras
    Attachments:
    test_temp.vi ‏25 KB

  • How to approach for downloading a CSV file?

    I'm running the following query and  QoQ . Could you tell me how should I proceed for the "Download  CSV" file option?
        <!--- QoQ for FIRSTCONN --->
        <cfquery datasource = "XX.XX.X.XX" name="master1">
             SELECT STR_TO_DATE(date_format(Timedetail,'%m-%d-%Y'),'%m-%d-%Y') as FIRSTCONN
                    , COUNT(Timedetail) as FIRSTOccurances
                    , EVENTS
             FROM  MyDatabase
             WHERE EVENTS = "FIRST"
             GROUP BY FIRSTCONN ;
        </cfquery>
        <!--- Detail Query --->
        <cfquery dbtype="query" name="detail1">
            SELECT  *
            FROM master1
            WHERE FIRSTCONN  >= <cfqueryparam value="#form.startdate#" cfsqltype="cf_sql_varchar">
            AND   FIRSTCONN  <  <cfqueryparam value="#dateAdd('d', 1,form.enddate)#" cfsqltype="cf_sql_varchar">;
        </cfquery> 
        <!--- QoQ for SECONDCONN --->
        <cfquery datasource = "XX.XX.X.XX" name="master2">
            SELECT STR_TO_DATE(date_format(Timedetail,'%m-%d-%Y'),'%m-%d-%Y') as SECONDCONN
                   , COUNT(Timedetail) as SECONDOccurances
                   , EVENTS
            FROM  MyDatabase
            WHERE EVENTS = "SECOND"
            GROUP BY SECONDCONN ;
        </cfquery>
        <cfquery dbtype="query" name="detail2">
            SELECT  *
            FROM   master2
            WHERE  SECONDCONN  >= <cfqueryparam value="#form.startdate#" cfsqltype="cf_sql_varchar">
            AND    SECONDCONN  <  <cfqueryparam value="#dateAdd('d', 1,form.enddate)#" cfsqltype="cf_sql_varchar">;
        </cfquery> 
        <cfchart format="flash"  chartwidth="1000" chartheight="500" scalefrom="0" scaleto="50000" xAxisTitle="Dates" yaxistitle="Number of Connections">
             <cfchartseries  query="detail1" type="line" itemColumn="FIRSTCONN" valueColumn="FIRSTOccurances" >
             <cfchartseries  query="detail2" type="line" itemColumn="SECONDCONN" valueColumn="SECONDOccurances" >
             </cfchartseries>
        </cfchart>
    The cfform code I'm using is as follows:
    <cfform format="flash" preloader ="false">
    <cfformgroup type="horizontal">
      <cfinput type="dateField" name="startdate" label="Start Date" width="100" value="#form.startdate#">
      <cfinput type="dateField" name="enddate" label="End Date" width="100" value="#form.enddate#">
      <cfinput name="submitApply" type="submit" value = "Apply">
      <cfinput name="cancel" type="submit" value="Download CSV">
    </cfformgroup>
    Desired Output:
    I have attached the image for the output below. Please find it attached.
    Basically, if a date range is 21June to 21 July. The output must be as shown in the image. (I have omitted THIRDCONN etc for the sake of simplicity in my code).
    Please let me know how should I go about this problem and let me know if I can answer more questions.

    It's not built into the language. Your best bet is probably to put the CSV-Reading logic into its own class.
    Or find one of the thousands of classes that already implement such a thing.

  • How to save excel report as CSV file with ActiveX

    Hi,
    I'm trying to save my excel test report as a CSV file using ActiveX and I'm having difficulty getting started.  I can't find an invoke node method that enables CSV file conversion. 
    Can anyone shed light on this?  See attached screenshot.
    Thanks
     

    As long as you are using the Report Generation Toolkit, there is no need to use ActiveX for the purpose of saving the Excel file -- Save Report will do that for you.  You can then export (as text) all of the Excel data and use the Write Spreadsheet File to make the .CSV file.  Here is how I would rewrite the final bits of your code --
    I cleaned up the wires around Excel Easy Table a bit.  You'll see I made a VI Icon for Replace Filename, which does (I think) a nicer job of self-documenting than showing its Label.  To make the filename, add the correct extension (.xlsx for Excel, .csv for CSV), use Build Path to combine Folder and Filename, and wire to Save Report.
    The next two functions add the Extract Everything and Write to Spreadsheet, using a Comma as a separator, which makes a CSV copy for you.
    Bob Schor

  • How To Split Large Excel or CSV Files into Smaller Files

    Does anyone know how to split a large Excel or CSV file into multiple smaller files?  Or, is there an app that will work with Mac to do that?

    split [-a suffix_length] [-b byte_count[k|m]] [-l line_count] [-p pattern] [file [name]]
    is a native Terminal command. Read up more on https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/ man1/split.1.html
    I prefer to use gSplit which is gnu coreutils.
    You can install gnu coreutils using homebrew.

  • How to invoke and receive from csv file

    I have an employee.csv file which contains empid and empname deatils,
    I want to fetch corresponding empid by giving input as empname from the employee.csv file and write empid into DB
    I had created an read file for employee.csv, but for the receive activity only one variable is created
    how to give input(empname) to the file and to get the empid from that file.
    Please help me from this issue

    In receive activity output file will contain the information of the entire list of empid and emp names. Wrive java code in java embedded activity to fetch the details of your desired output then use assign activity to continue your flow.
    try {                
    oracle.xml.parser.v2.XMLText text =(oracle.xml.parser.v2.XMLText)getVariableData("OnMessage_composeAndDistributeMQ_InputVariable","payload","/client:composeAndDistributeRequest/client:ControlInformation/client:SystemID/text()");
    String SystemID = text.getNodeValue();
    Calendar cal = Calendar.getInstance();
    SimpleDateFormat justDateTime = new SimpleDateFormat("yyyyMMddHHmmss");
    String DateTimeString = justDateTime.format(cal.getTime());
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
    Date now = new Date();
    addAuditTrailEntry("Now = " + df.format(now));
    long timeInMilli = now.getTime();
    addAuditTrailEntry("Date() - Time in milliseconds: " + now.getTime());
    String DRI = SystemID + "003" + DateTimeString + timeInMilli + "0000001";
    setVariableData("Invoke_RequestMQ", "body", "/ns2:DocumentRequests/ns2:DocumentRequest/ns2:MailItemInfo/ns2:DocumentRequestId", new String(DRI));
    catch (Exception e) {                
    e.printStackTrace();
    }

  • How to delete contents of a csv file except header using powershell

    Hi,
    I am trying to delete all the content of my csv file except its header. currently I am using clear-content but using this headers are also getting deleted. Basically I need a command which deletes all the rows of a csv file except first row.Please help.

    I'm only going to respond to prove that the useless troll is useless and wrong.
    Perhaps someday the troll will finally realize that it is worthless and will go away. No one cares about what it has to say and no one has ever found it to be helpful. Even good information is bad information when it is presented in an insulting, blathering,
    incoherent, and belittling tone. Plus, I think it's really funny when something tries to justify its own sad existence by making itself feel superior (when it clearly isn't). Sometimes I almost feel bad for it, but then it reminds me of how big of a jerk it
    really is.
    Get a life, get some friends, just go do something that isn't totally worthless (yeah, I know, you can't..).
    Don't retire TechNet! -
    (Don't give up yet - 12,700+ strong and growing)

  • How to generate report output in csv file and send it to user email inbox

    Hi All,
    We have requiremnt to generate the csv file from the report (Bex query)automatically and need to send that file automatically to user email address every week.
    It should be done automatically and one more thing the file name should contain that particuar date
    for example if we generate file automatically today the file name should be like below.
    US_04_15_2009.CSV
    Any one have any ideas?
    Regards,
    Sirisha

    Hi Arun Varadarajan.
    Thanks for your reply.We are in BI 7.0.Can you tell me how to  broadcast the query as CSV.Please let me know  if there is any possiblity to display or change the file name dynamically  based on system date.
    Regards,
    Sirisha
    Edited by: sirisha Nekkanti on Apr 16, 2009 4:08 AM

Maybe you are looking for