Comments (15)
Got it, I was able to parse a csv with okio's new multiplatform file system feature so I'm all good now. You might find it interesting.
from kotlin-csv.
No, there's no bottleneck.
But I wait to implement it because the multiplatform feature is now experimental and I don't see how big the need for the multiplatform feature is in kotlin-csv.
If this feature is needed, I'll consider it.
Feel free to request it, and tell me the detail of the use case.
from kotlin-csv.
Yeah so I quickly copied the sources into my project and was able to get encoding / decoding support on Kotlin Native. My implementation for ICsvFileWriter
is very trivial though. I just use a StringBuilder
and append characters into that instead of using the PrintWriter
from Java World.
from kotlin-csv.
Are there any bottlenecks preventing you from also targeting native?
from kotlin-csv.
@doyaaaaaken I see. Let me take this discussion internally and I will get back to you on our plans.
from kotlin-csv.
I don't know why this library is listed as "A pure kotlin simple csv reader/writer." when it only supports Kotlin JS or Kotlin JVM (and not actual Kotlin native).
What would be needed to take it completely Kotlin native actually?
from kotlin-csv.
Desperately hope to be able to support kotlin/common. I wanna phrase the csv in my shared module of KMM project, but I don't have a good way.
from kotlin-csv.
I guess the easiest solution would be to split the current library into two modules.
- encoding / decoding logic
- writing to IO
The first part could be truly multiplatform. The 2nd part could support the targets we have in place already and use the 1st part as a dependency.
In my personal preference, I'd even use okio for the second bit since you can't beat their APIs and I'm already leveraging it anyways.
from kotlin-csv.
@doyaaaaaken my team is interested in multiplatform version of kotlin-csv. We are developing a client-facing SDK that cross-compiles to JVM/Android/iOS/JS (both browser and NodeJS). I understand that some features would be unimplementable, specifically those working with files from browser, so some analysis would have to done in that respect.
We can probably even spare some manpower to work on enabling such support in kotlin-csv if you agree on the general direction.
from kotlin-csv.
@itegulov
Thank you very much. I would be very grateful for your help.
As you can see from the following code, the common code is in the form of receiving String type as an argument, and the rest is defining methods to receive each platform's own type (java.io.File type for Java) as an argument.
The first thing we would like to do is to make the minimal code defined in [the multiplatform code](https://github.com/doyaaaaaken/kotlin-csv/blob/master/src/commonMain/kotlin/com/github/doyaaaaaken/kotlincsv/client/
CsvReader.kt) work on a specific platform (e.g. JS).
What form of help would you be able to provide?
from kotlin-csv.
The Kotlin/JS feature is implemented by #30. (released at version 1.0.0.)
This issue is renamed into "Kotlin/Native Support".
from kotlin-csv.
Desperately hope to be able to support kotlin/common. I wanna phrase the csv in my shared module of KMM project, but I don't have a good way.
@onekinn1023
If you need something now for reading data. Here's an example little helper function for you using okio and multik for reading doubles with null support, you just need to define the filesytem actual in each target. This if for tab separated data, replace \t
in it.split('\t')
with whatever your delimiter is.
Multik isn't needed if you are okay with lists of lists.
expect val fileSystem : okio.FileSystem
protected fun loadTrainingData(path: Path, skipFirstRows: Int): D2Array<Double> {
val rows = fileSystem.read(path) {
generateSequence { readUtf8Line() }.filterIndexed{ i, s -> i >= skipFirstRows}
.map { it.split('\t').map { n -> if (n.contains("null")) 0.0 else n.toDouble() } }.toList()
}
return Mk.ndarray(rows)
}
from kotlin-csv.
I'm currently parsing line by line with pure kotlin code in my common module of KMM, but the resulting problem is that the format requirements of the source data need to be very standardized, and the maintenance of the code is also very troublesome. So I'm looking for a way that can be directly parsed from csv into a model or something... All in all, thanks for your @luca992 reply.
from kotlin-csv.
Splitting the common logic from the i/o is a good approach. It's been a couple of years since I looked under the hood of this library when I submitted #87. It may not be desirable to tie this library to Okio however since users may not want that dependency. Another approach would be to use Flows to communicate between the common logic and the platform-specific io, which could then be pluggable, with Okio as one implementation option.
from kotlin-csv.
kotlinx-io could be another option, which may be more acceptable to have as a direct dependency.
from kotlin-csv.
Related Issues (20)
- Make CsvFileReader.readNext() private HOT 6
- Keep input stream open HOT 2
- Optimize writeNext Method HOT 3
- The binary version of its metadata is 1.6.0, expected version is 1.4.2.
- Seeing a parsing error when quotes within text HOT 1
- Parser unable to parse csv file with lower row quantity compare with header HOT 6
- Introduce `insufficientFieldsRowBehaviour = "EMPTY_STRING"` option on CSV reader HOT 2
- How to read big csv file using your library?
- CsvFileWriter.writeRows writes line terminator even when passed list or sequence is empty HOT 3
- Allow an error interface channnel HOT 1
- Unable to parse with multiple quotes HOT 1
- Exception in thread "main" com.github.doyaaaaaken.kotlincsv.util.CSVParseFormatException: must appear escapeChar(") after escapeChar(") [rowNum = 729, colIndex = 467, char = "]
- Add support for WebAssembly HOT 2
- Use java.nio.Path instead of File
- Allow writing data with headers
- Make common ancestor for CsvReaderContext and CsvWriterContext
- Remove logger 3rd party library HOT 8
- java.lang.NoClassDefFoundError: com/github/doyaaaaaken/kotlincsv/dsl/CsvReaderDslKt HOT 1
- How to set/get Header HOT 1
- Write directly to a String HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kotlin-csv.