-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathDEVFileReaderCSV.xml
129 lines (113 loc) · 3.15 KB
/
DEVFileReaderCSV.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?xml version="1.0" encoding="utf-8"?>
<AxClass xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Name>DEVFileReaderCSV</Name>
<SourceCode>
<Declaration><![CDATA[
using Microsoft.VisualBasic.FileIO;
class DEVFileReaderCSV extends DEVFileReaderBase
{
}
]]></Declaration>
<Methods>
<Method>
<Name>readCSVFile</Name>
<Source><![CDATA[
public void readCSVFile(System.IO.Stream _stream, str _inFieldDelimiter = ',')
{
this.parmInFieldDelimiter(_inFieldDelimiter);
this.openFile(_stream);
}
]]></Source>
</Method>
<Method>
<Name>openFile</Name>
<Source><![CDATA[
public void openFile(System.IO.Stream _stream)
{
container rowData;
this.initNewFile();
if (! _stream )
{
return;
}
TextFieldParser parser = new TextFieldParser(_stream);
parser.SetDelimiters(inFieldDelimiter ? inFieldDelimiter : ',');
parser.set_HasFieldsEnclosedInQuotes(isIgnoreCSVQuotes ? false : true);
parser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType::Delimited;
parser.TrimWhiteSpace = false;
System.String[] netArray;
int xppArrayLength;
netArray = parser.ReadFields();
if (netArray != null)
{
xppArrayLength = netArray.get_Length();
}
while(xppArrayLength)
{
int counter;
str xppValue;
rowData = conNull();
for(counter = 1; counter <= xppArrayLength; counter++)
{
xppValue = netArray.GetValue(counter-1);
rowData += xppValue;
}
if (rowData != conNull())
{
excelDataCon += [rowData];
rowsCount++;
}
else
{
break;
}
netArray = parser.ReadFields();
if (netArray != null)
{
xppArrayLength = netArray.get_Length();
}
else
{
break;
}
}
if (_stream)
{
_stream.Close();
}
/*
If you don't want VisualBasic.FileIO reference
TextIO file;
FileIOPermission FIOPermission;
container rowData;
;
rowsCount = 0;
excelDataCon = conNull();
updatedRecords = 0;
insertedRecords = 0;
skippedRecords = 0;
if (! _fileName )
{
return;
}
FIOPermission = new FileIOPermission(_filename ,#IO_READ);
FIOPermission.assert();
file = new TextIO(_filename, #IO_Read);
file.inFieldDelimiter(inFieldDelimiter);
file.inRecordDelimiter(#delimiterCRLF);
while (file.status() == IO_Status::Ok)
{
rowData = file.read(); // To read file
if (rowData != conNull())
{
excelDataCon += [rowData];
rowsCount++;
}
}
*/
}
]]></Source>
</Method>
</Methods>
</SourceCode>
</AxClass>