https://loizenai.com Programming Tutorial
1620400234
https://grokonez.com/kotlin/kotlin-read-write-csv-file-example
How to read/write CSV file in Kotlin
In this tutorial, we’re gonna look at examples that read and write CSV file using native Kotlin.
package com.javasampleapproach.kotlin.csv
class Customer {
var id: String? = null
var name: String? = null
var address: String? = null
var age: Int = 0constructor() {} constructor(id: String?, name: String?, address: String?, age: Int) { this.id = id this.name = name this.address = address this.age = age } override fun toString(): String { return "Customer [id=" + id + ", name=" + name + ", address=" + address + ", age=" + age + "]" }
}
More at:
https://grokonez.com/kotlin/kotlin-read-write-csv-file-example
How to read/write CSV file in Kotlin
#csv #kotlin #read-file #write-file
https://loizenai.com Programming Tutorial
1620400234
https://grokonez.com/kotlin/kotlin-read-write-csv-file-example
How to read/write CSV file in Kotlin
In this tutorial, we’re gonna look at examples that read and write CSV file using native Kotlin.
package com.javasampleapproach.kotlin.csv
class Customer {
var id: String? = null
var name: String? = null
var address: String? = null
var age: Int = 0constructor() {} constructor(id: String?, name: String?, address: String?, age: Int) { this.id = id this.name = name this.address = address this.age = age } override fun toString(): String { return "Customer [id=" + id + ", name=" + name + ", address=" + address + ", age=" + age + "]" }
}
More at:
https://grokonez.com/kotlin/kotlin-read-write-csv-file-example
How to read/write CSV file in Kotlin
#csv #kotlin #read-file #write-file
https://loizenai.com Programming Tutorial
1620400658
https://grokonez.com/kotlin/kotlin-read-write-excel-file-apache-poi-example
Kotlin – How to read/write Excel file with Apache POI
In this tutorial, we’re gonna look at Kotlin examples that read and write Excel file using Apache POI.
<dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-stdlib</artifactId> <version>1.2.21</version> </dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
package com.javasampleapproach.kotlin.apachecsv
class Customer {
var id: String? = null
var name: String? = null
var address: String? = null
var age: Int = 0constructor() {} constructor(id: String?, name: String?, address: String?, age: Int) { this.id = id this.name = name this.address = address this.age = age } override fun toString(): String { return "Customer [id=" + id + ", name=" + name + ", address=" + address + ", age=" + age + "]" }
}
More at:
https://grokonez.com/kotlin/kotlin-read-write-excel-file-apache-poi-example
Kotlin – How to read/write Excel file with Apache POI
#kotlin #apache-poi #excel #read-file #write-file
https://loizenai.com Programming Tutorial
1618853674
https://ozenero.com/kotlin-properties-read-write-properties-file-properties-xml-file
Kotlin Properties – Read/Write Properties from/to .properties/.XML File
In the post, we show how to Read/Write Properties from/to .Properties/.XML files by Kotlin language.
java.util.Properties.store()
methods:
// 1.
fun store(out: OutputStream, comments: String): Unit
-> Writes this property list (key and element pairs) in this Properties table
to the output stream in a format suitable for loading into a Properties table using the load(InputStream) method.
// 2.
fun store(writer: Writer, comments: String): Unit
-> Writes this property list (key and element pairs) in this Properties table
to the output character stream in a format suitable for using the load(Reader) method.
More at:
https://ozenero.com/kotlin-properties-read-write-properties-file-properties-xml-file
Kotlin Properties – Read/Write Properties from/to .properties/.XML File
#kotlin #xml #read-file #write-file
https://loizenai.com Programming Tutorial
1621164290
https://grokonez.com/python/how-to-read-write-csv-files-in-python-csv-module
How to read/write CSV files in Python
In this tutorial, we’re gonna look at way to use csv
module to read, write CSV files in Python program.
For example:
Title,Category,Date
Python String methods,Python,12/27/2018
How to iterate over a List in Java,Java,12/21/2018
Kotlin List functions,Kotlin,12/19/2018
Instead of commas, cells could be separated with tab characters:
Title Tags Date
Python String methods python, string 12/27/2018
How to iterate over a List in Python python, list 12/21/2018
Python List functions python, list 12/19/2018
CSV file is simple than Excel spreadsheet because it doesn’t have:
csv
module
- open CSV file using open()
function
- create a Reader
object that lets you iterate over rows
- access values in the Reader
object by:
+ convert it to a plain Python list using list()
function
+ use for-loop (avoid loading the entire file into memory at once)
# cells are separated with commas >>> import csv >>> gkzFile = open('grokonez.csv') >>> csvReader = csv.reader(gkzFile) >>> gkzTuts = list(csvReader) >>> gkzTuts [['Title', 'Category', 'Date'], ['Python String methods', 'Python', '12/27/2018'], ['How to iterate over a List in Java', 'Java', '12/21/2018'], ['Kotlin List functions', 'Kotlin', '12/19/2018']] >>> gkzTuts[0][0] # data[row][col] 'Title' >>> gkzTuts[0][1] 'Category' >>> gkzTuts[0][2] 'Date' >>> gkzTuts[2][0] 'How to iterate over a List in Java' >>> gkzTuts[2][1] 'Java' >>> gkzTuts[2][2] '12/21/2018'
cells are separated with ‘tab’ characters
gkzFile = open(‘grokonez.csv’)
csvReader = csv.reader(gkzFile, delimiter=‘\t’)
gkzTuts = list(csvReader)
gkzTuts
[[‘Title’, ‘Tags’, ‘Date’], [‘Python String methods’, ‘python, string’, ‘12/27/2018’], [‘How to iterate over a List in Python’, ‘python, list’, ‘12/21/2018’], [‘Python List functions’, ‘python, list’, ‘12/19/2018’]]
gkzTuts[0][0]
‘Title’
gkzTuts[0][1]
‘Tags’
gkzTuts[0][2]
‘Date’
gkzTuts[2][0]
‘How to iterate over a List in Python’
gkzTuts[2][1]
‘python, list’
gkzTuts[2][2]
‘12/21/2018’
Reader
object only once.Reader
object again.
More at:
https://grokonez.com/python/how-to-read-write-csv-files-in-python-csv-module
How to read/write CSV files in Python
#python #csv #read #write
https://loizenai.com Programming Tutorial
1620403024
https://grokonez.com/kotlin/kotlin-how-to-read-write-csv-file-with-opencsv-example
Kotlin – How to read/write CSV file with OpenCSV
In this tutorial, we’re gonna look at Kotlin examples that read and write CSV file using OpenCSV.
<dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-stdlib</artifactId> <version>1.2.21</version> </dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>4.0</version>
</dependency>
var fileWriter = FileWriter("customer.csv")
csvWriter = CSVWriter(fileWriter,
CSVWriter.DEFAULT_SEPARATOR,
CSVWriter.NO_QUOTE_CHARACTER,
CSVWriter.DEFAULT_ESCAPE_CHARACTER,
CSVWriter.DEFAULT_LINE_END)
val data = arrayOf(“ID”,“NAME”,“ADDRESS”,“AGE”)
csvWriter.writeNext(data)
More at:
https://grokonez.com/kotlin/kotlin-how-to-read-write-csv-file-with-opencsv-example
Kotlin – How to read/write CSV file with OpenCSV
#kotlin #csv-file #opencsv