1 package net.sf.pzfilereader.examples.multilinedelimitedrecord;
2
3
4
5
6
7
8 import java.io.File;
9
10 import net.sf.pzfilereader.DataSet;
11 import net.sf.pzfilereader.DefaultPZParserFactory;
12 import net.sf.pzfilereader.DataSet;
13 import net.sf.pzfilereader.PZParser;
14
15 /**
16 * @author zepernick
17 *
18 * TODO To change the template for this generated type comment go to Window -
19 * Preferences - Java - Code Style - Code Templates
20 */
21 public class DelimitedMultiLine {
22
23 public static void main(final String[] args) throws Exception {
24 String data = getDefaultDataFile();
25 try {
26 call(data);
27 } catch (Exception e) {
28
29 e.printStackTrace();
30 }
31 }
32
33 public static String getDefaultDataFile() {
34 return "PEOPLE-CommaDelimitedWithQualifierMultiLine.txt";
35 }
36
37 public static void call(String data) throws Exception {
38
39
40
41 final PZParser pzparser = DefaultPZParserFactory.getInstance().newDelimitedParser(new File(data),
42 ',', '\"');
43 final DataSet ds = pzparser.parse();
44
45 final String[] colNames = ds.getColumns();
46
47 while (ds.next()) {
48 for (int i = 0; i < colNames.length; i++) {
49 System.out.println("COLUMN NAME: " + colNames[i] + " VALUE: " + ds.getString(colNames[i]));
50 }
51
52 System.out.println("===========================================================================");
53 }
54
55 if (ds.getErrors() != null && ds.getErrors().size() > 0) {
56 System.out.println("FOUND ERRORS IN FILE");
57 }
58
59 }
60 }