Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lizardon/CSV4AS3
CSV library for Actionscript ported from Apache Commons CSV
https://github.com/lizardon/CSV4AS3
Last synced: about 2 months ago
JSON representation
CSV library for Actionscript ported from Apache Commons CSV
- Host: GitHub
- URL: https://github.com/lizardon/CSV4AS3
- Owner: lizardon
- Created: 2013-07-14T04:19:10.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-09-22T11:53:38.000Z (over 11 years ago)
- Last Synced: 2024-08-03T05:02:51.690Z (5 months ago)
- Language: ActionScript
- Size: 133 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-actionscript-sorted - CSV4AS3 - CSV library for Actionscript ported from Apache Commons CSV (File Formats / Misc Formats)
README
CSV4AS3 is a CSV library for Actionscript that has been ported from Apache Commons CSV
Advantages of this library include:
* Ability to parse incrementally without the need to read entire file into memory
* Support for custom CSV format settings
* Support for handling escapes and comments
* Includes a CSV printer
* Supports UTF8 compatible text formatsGetting Started - Parsing a CSV File
Step 1: Create and open a IDataInput object such as a FileStream
var file:File = new File("C:\\Users\\userdir\\test.csv");
var input:FileStream = new FileStream();
input.open(file, FileMode.READ);Step 2: Create and Configure A CSVParser:
// in this case the CSV file has a header
var parser:CSVParser = new CSVParser(input, CSVFormat.buildDefaultWithHeader());
var headerMap:Object = parser.getHeaderMap();Step 3: Iterate over the records
var record:CSVRecord;
while(parser.hasNext())
{
record = parser.next();
for (var columnName:String in headerMap)
{
trace(columnName + ": " + record.getValueByName(columnName));
}
}Alternatively parser.getRecords() will return an Array of CSVRecords of all the remaining rows in the file without needing to iterate.
Step 4: Close the input source
input.close();