libraries.Reader.pec Maven / Gradle / Ivy
define iterateCsv as native method receiving text, Text<:> columnNames = nothing, Character separator = ',', Character quote = '"' returning Iterator doing:
Java: return prompto.reader.CSVReader.iterator(text, columnNames, separator, quote);
C#: return prompto.reader.CSVReader.iterator(text, columnNames, separator, quote);
Python2: return csvIterate(text, columnNames, separator, quote) from module: prompto.reader.CSVReader
Python3: return csvIterate(text, columnNames, separator, quote) from module: prompto.reader.CSVReader
JavaScript: return csvIterate(text, columnNames, separator, quote); from module: prompto/reader/CSVReader.js
define readCsv as native method receiving text, Text<:> columnNames = nothing, Character separator = ',', Character quote = '"' returning Document[] doing:
Java: return prompto.reader.CSVReader.read(text, columnNames, separator, quote);
C#: return prompto.reader.CSVReader.read(text, columnNames, separator, quote);
Python2: return csvRead(text, columnNames, separator, quote) from module: prompto.reader.CSVReader
Python3: return csvRead(text, columnNames, separator, quote) from module: prompto.reader.CSVReader
JavaScript: return csvRead(text, columnNames, separator, quote); from module: prompto/reader/CSVReader.js
define readCsvHeaders as native method receiving text, Character separator = ',', Character quote = '"' returning Text[] doing:
Java: return prompto.reader.CSVReader.readHeaders(text, separator, quote);
C#: return prompto.reader.CSVReader.readHeaders(text, separator, quote);
Python2: return csvReadHeaders(text, separator, quote) from module: prompto.reader.CSVReader
Python3: return csvReadHeaders(text, separator, quote) from module: prompto.reader.CSVReader
JavaScript: return csvReadHeaders(text, separator, quote); from module: prompto/reader/CSVReader.js
define "reads from csv text" as test method doing:
docs = readCsv with "id,name\n1,John\n2,Riou\\, Sylvie\n" as text
and verifying:
docs.count = 2
docs[1].id = "1"
docs[1].name = "John"
docs[2].id = "2"
docs[2].name = "Riou, Sylvie"
define "reads headers from csv text" as test method doing:
headers = readCsvHeaders with "id,name\n1,John\n2,Riou\\, Sylvie\n" as text
and verifying:
headers.count = 2
headers[1] = "id"
headers[2] = "name"
define "iterates from csv text" as test method doing:
iterCsv = iterateCsv with "id,name\n1,John\n2,Riou\\, Sylvie\n" as text
docs = [] as Document[]
for each doc in iterCsv:
docs = docs + [doc]
and verifying:
docs.count = 2
docs[1].id = "1"
docs[1].name = "John"
docs[2].id = "2"
docs[2].name = "Riou, Sylvie"
define "maps csv headers" as test method doing:
names = < "Code" : "id", "Name" : "name" >
docs = readCsv with "Code,Name\n1,John\n2,Riou\\, Sylvie\n" as text and names as columnNames
and verifying:
docs.count = 2
docs[1].id = "1"
docs[1].name = "John"
docs[2].id = "2"
docs[2].name = "Riou, Sylvie"
define writeCsv as native method receiving Document[] docs, Text[] columnsList, Text<:> columnNames = nothing, Character separator = ',', Character quote = '"' returning Text doing:
Java: return prompto.writer.CSVWriter.write(docs, columnsList, columnNames, separator, quote);
C#: return prompto.writer.CSVWriter.write(docs, columnsList, columnNames, separator, quote);
Python2: return csvWrite(docs, columnsList, columnNames, separator, quote) from module: prompto.writer.CSVWriter
Python3: return csvWrite(docs, columnsList, columnNames, separator, quote) from module: prompto.writer.CSVWriter
JavaScript: return csvWrite(docs, columnsList, columnNames, separator, quote); from module: prompto/writer/CSVWriter.js
define "writes csv to text" as test method doing:
doc = { firstName: "John", lastName: "Smith", birthDate: '1212-12-12', salary: 22222 }
text = writeCsv with [ doc ] as docs, ["firstName", "lastName", "birthDate", "salary"] as columnsList, < "firstName": "First name", "lastName" : "Last name", "birthDate": "Birth date" > as columnNames
and verifying:
text = "First name,Last name,Birth date,salary\nJohn,Smith,1212-12-12,22222\n"
define readJson as native method receiving text returning Any doing:
Java: return prompto.reader.JSONReader.read(text);
C#: return prompto.reader.JSONReader.read(text);
Python2: return jsonRead(text) from module: prompto.reader.JSONReader
Python3: return jsonRead(text) from module: prompto.reader.JSONReader
JavaScript: return jsonRead(text); from module: prompto/reader/JSONReader.js
define "test that readJson returns a boolean" as test method doing:
o = readJson "true"
and verifying:
o is a Boolean
o is true
define "test that readJson returns an Integer" as test method doing:
o = readJson "237"
and verifying:
o is an Integer
o = 237
define "test that readJson returns a Decimal" as test method doing:
o = readJson "123.02"
and verifying:
o is a Decimal
o = 123.02
define "test that readJson returns a Text" as test method doing:
o = readJson "\"some text\""
and verifying:
o is a Text
o = "some text"
define "test that readJson returns a Document" as test method doing:
o = (readJson "{\"field\":122}") as Document
and verifying:
o is a Document
o.field = 122
define "test that readJson returns a List" as test method doing:
o = (readJson "[{\"field\":122}]") as Document[]
and verifying:
o is a Document[]
o[1].field = 122
define "test that readJson returns a complex Document" as test method doing:
json = "[{\"field\":122, \"list\": [{\"field\":123, \"doc\": {\"name\": \"John\"}}], \"doc\": { \"list\": [ 122, 233, 344] }}]"
o = (readJson json) as Document[]
and verifying:
o is a Document[]
o[1].field = 122
define readXml as native method receiving text, Boolean keepNamespaces = false and Boolean keepAttributes = false returning Document doing:
Java: return prompto.reader.XMLReader.read(text, keepNamespaces, keepAttributes);
C#: return prompto.reader.XMLReader.read(text, keepNamespaces, keepAttributes);
Python2: return xmlRead(text, keepNamespaces, keepAttributes) from module: prompto.reader.XMLReader
Python3: return xmlRead(text, keepNamespaces, keepAttributes) from module: prompto.reader.XMLReader
JavaScript: return xmlRead(text, keepNamespaces, keepAttributes); from module: prompto/reader/XMLReader.js
define "readXml returns a Document" as test method doing:
xml = "abc"
o = readXml xml
and verifying:
o is a Document
o.a.b = "abc"
define writeXml as native method receiving Document doc returning Text doing:
Java: return prompto.writer.XMLWriter.write(doc);
C#: return prompto.writer.XMLWriter.write(doc);
Python2: return xmlWrite(doc) from module: prompto.writer.XMLWriter
Python3: return xmlWrite(doc) from module: prompto.writer.XMLWriter
JavaScript: return xmlWrite(doc); from module: prompto/writer/XMLWriter.js
define "writeXml writes a Document" as test method doing:
src = { a: { b: "abc" } }
xml = writeXml src
dst = readXml xml
and verifying:
dst is a Document
dst = src
define readYaml as native method receiving text returning Document[] doing:
Java: return prompto.reader.YAMLReader.read(text);
C#: return prompto.reader.YAMLReader.read(text);
Python2: return yamlRead(text) from module: prompto.reader.YAMLReader
Python3: return yamlRead(text) from module: prompto.reader.YAMLReader
JavaScript: return yamlRead(text); from module: prompto/reader/YAMLReader.js
define "test that readYaml returns a complex Document" as test method doing:
yaml = "field: 122\ndata:\n list:\n - field: 123\n - doc:\n name: John\n doc:\n list:\n - 122\n - 233\n - 344"
o = readYaml yaml
and verifying:
o is a Document[]
o[1].field = 122
define writeYaml as native method receiving Document[] docs returning Text doing:
Java: return prompto.writer.YAMLWriter.write(docs);
C#: return prompto.writer.YAMLWriter.write(docs);
Python2: return yamlWrite(docs) from module: prompto.writer.YAMLWriter
Python3: return yamlWrite(docs) from module: prompto.writer.YAMLWriter
JavaScript: return yamlWrite(docs); from module: prompto/writer/YAMLWriter.js
define "test that writeYaml writes a complex Document" as test method doing:
src = [{ field: 122, list: [ { field: 123 }, { doc: { name: "John", doc: { list: [ 122, 233, 344 ] } } } ] }]
yaml = writeYaml src
dst = readYaml yaml
and verifying:
dst is a Document[]
dst = src
© 2015 - 2024 Weber Informatics LLC | Privacy Policy