Giter Site home page Giter Site logo

jcsv's People

jcsv's Issues

suggestion - add newLine to CSVStrategy

What steps will reproduce the problem?
1. There is webapp running on unix that is relying on system property 
"line.separator", so cannot change that. And requirement is that jcsv is 
generating CRLF rows.

What is the expected output? What do you see instead?
What i'm using is:
Changed in com.googlecode.jcsv.CSVStrategy

  private final String newLine;
  public String getNewLine() {...}
  public CSVStrategy-constructor modified to accept String newLine parameter
  ...DEFAULT and UK_DEFAULT strategies updated to read System.getProperty("line.separator")

Changed in com.googlecode.jcsv.writer.internal.CSVWriterImpl
  // method
  public void write(E e) throws IOException {
  ...
  sb.append(strategy.getNewLine());
  // replaced the old line: sb.append(System.getProperty("line.separator"));
  ...
  }

What version of the product are you using? On what operating system?
jcsv-1.4.0, on Linux app1 2.6.16.60-0.21-xen, java version "1.6.0_34" 64-Bit 
Server

Please provide any additional information below.
No rush, it's working fine with my modifications just trying to share idea.

Original issue reported on code.google.com by [email protected] on 4 Jun 2013 at 12:59

How do I write a CSV file with a header?

StringWriter sw = new StringWriter();
CSVWriter csvWriter = new CSVWriterBuilder(sw)
 .entryConverter(new MyConverter()).strategy(
 new CSVStrategy('\t', '\"', '#', false, true)).build();

//Add the header row
csvWriter.write(new String[] { "col1", "col2", "col3" });

csvWriter.writeAll(editors);

String csvData = sw.toString();

??

Original issue reported on code.google.com by [email protected] on 7 Feb 2013 at 5:46

AnnotationEntryParser not compatible with inheritance

I was trying to use the annotation MapToColumn in my User class.
But it didn't work and I had troubles figuring out why.
Eventually I did, only by reading the code, in particular 
`AnnotationEntryParser#fillObject`.


The problem is that I have a hierarchy Actor <= User
with some annotated fields in the superclass and some in the subclass.
And it turns out that #fillObject uses `entry.getClass().getDeclaredFields()`
which does not access fields in superclasses.
Fair enough to me, as I see that #getFields can access fields in superclasses 
but only public ones.

So, I think this just needs to be clarified in the wiki page:
https://code.google.com/p/jcsv/wiki/CSVReader#Create_Java_objects_using_annotati
ons


Btw, I/m on v1.4.0.

Thx

AS


Example
-------

public class AnnotatedPerson {

      @MapToColumn(column=0)
      protected String firstname;

      @MapToColumn(column=1)
      protected String lastname;


      @Override
      public String toString() {
        return String.format("%s %s  years", firstname, lastname);
      }

public class Employee extends AnnotatedPerson {

    @MapToColumn(column=2)
    private int age;

    @Override
    public String toString() {
        return super.toString() + " " + age;
    }
  }

Original issue reported on code.google.com by [email protected] on 11 Jun 2014 at 11:37

readHeader() doesn't parse the comma separated header fields

What steps will reproduce the problem?
1. call CsvReader.readHeader()
2.
3.

What is the expected output? What do you see instead?

I expect the List<String> will contain a list of headers for each comma 
separated field.  Instead it gives the entire line, unparsed.  I would have to 
write a csv parser myself to parse the header line.  Useless.


What version of the product are you using? On what operating system?

1.4.0 on JDK 1.7 on Windows 7 enterprise.


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 2 Mar 2014 at 10:41

Exception when handling null field in the object

What steps will reproduce the problem?
1. Try to generate a CSV list with 3 fields-(field1, field2, field3) with a 
empty filed, for example "3,null,1"
2. Then the code will throw a NullPointerException

This is because there is a bug  when library dealing with null fields in the 
object, it throws a NullPointerException because in the highlighted areas 
below, it should check if data[i] is null or not first, before it jumps the gun 
trying to access it's content via contains...

A easy fix see below: check if data[i] is null or not first, before it jumps 
the gun trying to access it's content via contains.

public class CSVColumnJoinerImpl implements CSVColumnJoiner {

    @Override
    public String joinColumns(String[] data, CSVStrategy strategy) {
        final String delimiter = String.valueOf(strategy.getDelimiter());
        final String quote = String.valueOf(strategy.getQuoteCharacter());
        final String doubleQuote = quote + quote;

        // check each column for delimiter or quote characters
        // and escape them if neccessary
        for (int i = 0; i < data.length; i++) {
            if (data[i].contains(delimiter) || data[i].contains(quote)) {
                if (data[i].contains(quote)) {
                    data[i] = data[i].replaceAll(Pattern.quote(quote), doubleQuote);
                }

                data[i] = quote + data[i] + quote;
            }
        }

        return CSVUtil.implode(data, delimiter);
    }

}

What is the expected output? What do you see instead?
A CSV with empty for null field.
Exception.

What version of the product are you using? On what operating system?
Version: 1.4.0
OS: windows

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 20 Mar 2013 at 12:15

Add ability to change DataFormat for DateProcessor

Now it is impossible to change DateFormat in DateProcessor.

ValueProcessorProvider creates DateProcessor uses constructor with DateFormat 
argument:
registerValueProcessor(Date.class, new 
DateProcessor(DateFormat.getDateInstance()));

It will be usable to have ability to set DateFormat for java.util.Date format?

Original issue reported on code.google.com by [email protected] on 20 Aug 2012 at 9:14

Quote new line characters

What steps will reproduce the problem?
1. Trying to generate a CSV file with 3 fields A, B, C
2. A - Number, B - Short name, C - Text entered by user (Element C might have 
multiple lines).

What is the expected output? What do you see instead?
Expecting to get valid CSV file with Quoted element C when element C has 
multiple lines, instead getting element C partially shifted to the next line.

What version of the product are you using? On what operating system?
<groupId>com.googlecode.jcsv</groupId>
<artifactId>jcsv</artifactId>
<version>1.4.0</version>

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 21 Nov 2014 at 10:43

Determine line being parsed

I'm using jcsv to parse a lot of csv files that frequently have small flaws. My 
intent is to use Scala's Either to produce a list of warnings and errors in the 
data while populating an internal table.

Having the line number available (from CSVReader?) would help. (I've hacked it 
together by adding a counter to my CSVEntryParser, but other people will need 
this.)

Thanks,

Dave

Original issue reported on code.google.com by [email protected] on 22 Jul 2013 at 7:25

Cache "System.getProperty("line.separator")" result instead of reading it for every line

When we profiled our application we noticed that a lot of time was spend in the 
"System.getProperty("line.separator")" call of the CSVWriterImpl.write(E e) 
method.

I attached a patch which modifies CSVWriterImpl to store the "line.separator" 
property in a private field. It would be nice if this patch is merged into a 
future release of jcsv. 

Thanks for providing this useful library. :=)



Original issue reported on code.google.com by [email protected] on 27 Sep 2013 at 6:18

Attachments:

Allow option fields

I must say, really nice implementation of CSV parser. Just a suggestion for the 
AnnotationEntryParser. You could allow optional fields as it is done for JPA 
entities. A implemented my self a solution and can provide you if you are 
interested.

Another question: how about migrating your awesome project to Github? I can 
help you if you want.

Cheers!

Original issue reported on code.google.com by [email protected] on 11 Aug 2013 at 4:29

Default to comma delimeter

All the examples assume a semicolon delimeter, but CSV (Comma Separated Value) 
most often uses commas. Is there an option to use a specific delimiter when 
parsing a file?

Original issue reported on code.google.com by [email protected] on 17 Dec 2013 at 7:21

Integer parse error on ""

When mapping an Integer field an it's value in the csv is "" the default 
IntegerProcessor throw an error.


Is there a way to override the default one ?


Original issue reported on code.google.com by [email protected] on 4 Feb 2013 at 5:20

Feature request: asynchronous output for large CSV files

For large CSV files, >30GB, it would be nice if jcsv's API gave output 
asynchronously, such as writing objects to an ObjectOut, rather than attempting 
to return a List of objects all at once.

Are there plans for large file support in jcsv? Is there another Java CSV 
library with this feature?

Original issue reported on code.google.com by [email protected] on 23 Jan 2014 at 7:23

Skipping odd lines from read operation

What steps will reproduce the problem?
1. A large csv file with 50K records, with header and 32 columns
2. Create parser as per documentation
3. Reader not reading odd records as shown.

49800,female,Mrs.,Tamara,E,Mahon,1488 Nelm Street,Mclean,VA,22102,US,United 
States,[email protected],Experwas,eiho4aGh,571-238-4010,Mays,9/5/1931,Mas
terCard,5299106877014245,156,10/2015,229-84-5708,1Z 967 073 22 0918 478 
3,Blue,Engineer,Maxaprofit,2000 Nissan 
Pathfinder,MagazineAlert.com,O+,158.4,72.0,5' 
4",162,940a615c-713f-4628-956f-b996555f5378,38.923747,-77.179214

49802,female,Ms.,Linda,K,Johnson,4883 Riverside 
Drive,Calhoun,GA,30701,US,United 
States,[email protected],Inny1948,bee9jeiGhai,706-879-7558,Ensor,9/8/1948,
Visa,4532498748712770,207,1/2017,257-62-7599,1Z 354 740 12 0282 847 
1,Purple,Principal secretary,Giant,1999 Volkswagen 
Caddy,DashboardDirectory.com,O+,192.5,87.5,5' 
1",155,29396371-43a5-4bc2-9add-838e1ce3547c,34.432252,-84.910133


What is the expected output? What do you see instead?

49799,female,Ms.,Sherry,M,Ferrara,1979 Parrish 
Avenue,Salinas,CA,93901,US,United 
States,[email protected],Judetted,Ieveakae0,831-232-6628,Lea,12/21/1
940,Visa,4916539410716635,440,1/2019,546-87-6644,1Z 986 21Y 74 9313 893 
7,White,Electronic home entertainment equipment repairer,Prahject Planner,2007 
Nissan Armada,EditFrog.com,O+,181.3,82.4,5' 
0",152,73f72d41-8b29-4dba-aa3d-bcf5cfbc933d,36.633136,-121.575138

49800,female,Mrs.,Tamara,E,Mahon,1488 Nelm Street,Mclean,VA,22102,US,United 
States,[email protected],Experwas,eiho4aGh,571-238-4010,Mays,9/5/1931,Mas
terCard,5299106877014245,156,10/2015,229-84-5708,1Z 967 073 22 0918 478 
3,Blue,Engineer,Maxaprofit,2000 Nissan 
Pathfinder,MagazineAlert.com,O+,158.4,72.0,5' 
4",162,940a615c-713f-4628-956f-b996555f5378,38.923747,-77.179214

49801,male,Mr.,Roy,L,Uchida,1153 Cedar Lane,Somerville,MA,02143,US,United 
States,[email protected],Tran1965,Koo3Noos,617-627-6284,George,5/16/1965,Vis
a,4916625742893489,974,7/2018,030-12-3911,1Z 732 592 11 0422 268 8,Blue,Floor 
layer,Richman Brothers,1999 Oldsmobile Intrigue,CozySlings.com,O+,174.9,79.5,6' 
1",185,9c3d7beb-e419-429c-9117-a8a4ff6ede6a,42.451697,-71.15309

49802,female,Ms.,Linda,K,Johnson,4883 Riverside 
Drive,Calhoun,GA,30701,US,United 
States,[email protected],Inny1948,bee9jeiGhai,706-879-7558,Ensor,9/8/1948,
Visa,4532498748712770,207,1/2017,257-62-7599,1Z 354 740 12 0282 847 
1,Purple,Principal secretary,Giant,1999 Volkswagen 
Caddy,DashboardDirectory.com,O+,192.5,87.5,5' 
1",155,29396371-43a5-4bc2-9add-838e1ce3547c,34.432252,-84.910133


What version of the product are you using? On what operating system? 1.4


Please provide any additional information below.

File header is as follows

Number,Gender,Title,GivenName,MiddleInitial,Surname,StreetAddress,City,State,Zip
Code,Country,CountryFull,EmailAddress,Username,Password,TelephoneNumber,MothersM
aiden,Birthday,CCType,CCNumber,CVV2,CCExpires,NationalID,UPS,Color,Occupation,Co
mpany,Vehicle,Domain,BloodType,Pounds,Kilograms,FeetInches,Centimeters,GUID,Lati
tude,Longitude


Original issue reported on code.google.com by [email protected] on 4 Mar 2014 at 4:34

append new line

What steps will reproduce the problem?
Normal CSVWriter, is it possible to open csv file attach new line of data at 
the end of the file and close filewriter

What is the expected output? What do you see instead?
csvWriter.write(point); is overwriting first line

What version of the product are you using? On what operating system?
last, maven

Please provide any additional information below.
Writer out = new FileWriter(filename, true); is not helping 

Original issue reported on code.google.com by [email protected] on 31 Jan 2013 at 11:16

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.