@sasjs/core 4.34.0 → 4.34.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base/mp_cleancsv.sas +13 -6
- package/package.json +1 -1
package/base/mp_cleancsv.sas
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
@file
|
|
2
|
+
@file
|
|
3
3
|
@brief Fixes embedded cr / lf / crlf in CSV
|
|
4
4
|
@details CSVs will sometimes contain lf or crlf within quotes (eg when
|
|
5
5
|
saved by excel). When the termstr is ALSO lf or crlf that can be tricky
|
|
@@ -7,14 +7,16 @@
|
|
|
7
7
|
This macro converts any csv to follow the convention of a windows excel file,
|
|
8
8
|
applying CRLF line endings and converting embedded cr and crlf to lf.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Usage:
|
|
11
11
|
|
|
12
12
|
fileref mycsv "/path/your/csv";
|
|
13
13
|
%mp_cleancsv(in=mycsv,out=/path/new.csv)
|
|
14
14
|
|
|
15
|
-
@param in=
|
|
16
|
-
|
|
17
|
-
@param
|
|
15
|
+
@param in= (NOTPROVIDED) Provide path or fileref to input csv. If a period is
|
|
16
|
+
found, it is assumed to be a file.
|
|
17
|
+
@param out= (NOTPROVIDED) Output path or fileref to output csv. If a period
|
|
18
|
+
is found, it is assumed to be a file.
|
|
19
|
+
@param qchar= ('22'x) Quote char - hex code 22 is the double quote.
|
|
18
20
|
|
|
19
21
|
@version 9.2
|
|
20
22
|
@author Allan Bowe
|
|
@@ -56,9 +58,14 @@
|
|
|
56
58
|
else do;
|
|
57
59
|
/* outside a quote, change cr and lf to crlf */
|
|
58
60
|
if inchar='0D'x then do;
|
|
61
|
+
crblank:
|
|
59
62
|
put '0D0A'x;
|
|
60
63
|
input inchar $char1.;
|
|
61
|
-
if inchar
|
|
64
|
+
if inchar='0D'x then do;
|
|
65
|
+
/* multiple CR indicates CR formatted file with blank lines */
|
|
66
|
+
goto crblank;
|
|
67
|
+
end;
|
|
68
|
+
else if inchar ne '0A'x then do;
|
|
62
69
|
put inchar $char1.;
|
|
63
70
|
if inchar=qchar then isq = mod(isq+1,2);
|
|
64
71
|
end;
|
package/package.json
CHANGED