Skip to content

Commit e5c5f68

Browse files
risenWgitbook-bot
authored andcommitted
GitBook: [#225] No subject
1 parent 245fa25 commit e5c5f68

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

api-reference/general-functions/danfo.streamcsvtransformer.md

+8-10
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,29 @@ description: >-
77

88
# danfo.streamCsvTransformer
99

10-
danfo.**streamCsvTransformer**(func) 
10+
danfo.**streamCsvTransformer**(func)
1111

1212
| Parameters | Type | Description |
1313
| ------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1414
| inputFilePath | Function | The path to the CSV file to stream from. |
15-
| transformer | Function | <p>The transformer function to apply to each row. </p><p>Note that each row of the CSV file is passed as a DataFrame with a single row to the transformer function, and the transformer function is expected to return a transformed DataFrame.</p> |
15+
| transformer | Function | <p>The transformer function to apply to each row.</p><p>Note that each row of the CSV file is passed as a DataFrame with a single row to the transformer function, and the transformer function is expected to return a transformed DataFrame.</p> |
1616
| options | object | <p>Configuration options for the pipeline. These include:</p><ul><li><code>outputFilePath</code> The local file path to write the transformed CSV file to.</li><li><code>customCSVStreamWriter</code> A custom CSV stream writer function. This is applied at the end of each transform. If not provided, a default CSV stream writer is used, and this writes to local storage.</li></ul><ul><li><code>inputStreamOptions</code> Configuration options for the input stream. Supports all Papaparse CSV reader config options.</li><li><code>outputStreamOptions</code> Configuration options for the output stream. This is only applied when using the default CSV stream writer. Supports all <code>toCSV</code> options.</li></ul> |
1717

1818
**Returns:**
1919

20-
> return A promise that resolves when the pipeline transformation is complete.
20+
> A promise that resolves when the pipeline transformation is complete.
2121
2222
The streamCsvTransformer can be used to [incrementally transform](https://en.wikipedia.org/wiki/Stream\_processing) a CSV file. This is done by:
2323

2424
* Streaming a CSV file from a local or **remote** path.
2525
* Passing each corresponding row as a DataFrame to the specified transformer function.
26-
* Writing the result to an output stream. &#x20;
27-
28-
26+
* Writing the result to an output stream.
2927

3028
## **Stream processing a local file**
3129

32-
In the example below, we stream a local CSV file (titanic.csv), applies a transformer function, and write the output to the `titanicOutLocal` file.
30+
In the example below, we stream a local CSV file (titanic.csv), apply a transformer function, and write the output to **`titanicOutLocal.csv`**.
3331

34-
The transformer takes each `Name` column, splits the person's title, and creates a new column from it.&#x20;
32+
The transformer takes each `Name` column, splits the person's title, and creates a new column from it.
3533

3634
{% tabs %}
3735
{% tab title="Node" %}
@@ -86,7 +84,7 @@ PassengerId,Survived,Pclass,Name,Sex,Age,SibSp,Parch,Ticket,Fare,Cabin,Embarked,
8684

8785
In the example below, we stream a remote CSV file (titanic.csv), applies a transformer function, and write the output to the `titanicOutLocal` file.
8886

89-
The transformer takes each `Name` column, splits the person's title, and creates a new column from it.&#x20;
87+
The transformer takes each `Name` column, splits the person's title, and creates a new column from it.
9088

9189
{% tabs %}
9290
{% tab title="Node" %}
@@ -121,7 +119,7 @@ dfd.streamCsvTransformer(inputFilePath, transformer, {
121119

122120
If you need custom control of the output writer, then you can provide a pipe-able custom writer. See [https://www.freecodecamp.org/news/node-js-streams-everything-you-need-to-know-c9141306be93/](https://www.freecodecamp.org/news/node-js-streams-everything-you-need-to-know-c9141306be93/)
123121

124-
In the example below, we add a custom writer that logs each row. You can extend this to upload each chunk to a database, or any other function you need.&#x20;
122+
In the example below, we add a custom writer that logs each row. You can extend this to upload each chunk to a database, or any other function you need.
125123

126124
{% tabs %}
127125
{% tab title="Node" %}

examples/migrating-to-the-stable-version-of-danfo.js.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The following list summarizes some of these updates:
1313
* **Typescript support:** This new version has been completely re-written using Typescript. This means we now have well-defined types that increase the developer experience.
1414
* **Standard naming convention:** Functions, methods, classes, and variable names have been standardized to follow JavaScript best practices.
1515
* Standardize function argument: Functions and methods have been updated to accept arguments and parameters intuitively resulting in improved developer experience.
16-
* **New features**: We added a couple of new features which users have been requesting for. For example:
16+
* **New features**: We added lots of new features which users have been requesting for. For example:
1717
* Stream and process large CSV data
1818
* General bug fixes and improvements
1919
* Better error messages
@@ -28,19 +28,19 @@ Update your function and/or method names to use camelCase instead of snake\_case
2828

2929
```javascript
3030
read_csv ==> readCSV
31-
to_json ==> toJSON
31+
to_json ==> toCSV
3232
drop_duplicates ==> dropDuplicates
3333
```
3434

35-
**Note:** that your code editor will generally suggest the new function or method names, so it will be easier to update to the new names. If using Typescript, then it is even easier as the TS compiler will show you warnings.
35+
**Note:** that your code editor auto-complete will general suggest the new function or method names, so it will be easier to update to the new names. If using Typescript, then it is even easier as the TS compiler will show you warnings.
3636

3737
### Functions and Methods argument structure
3838

3939
Another major breaking change of v1, is that the structure of arguments/parameters in most functions has been updated to be more intuitive.
4040

4141
In general, it is important to understand our thought process behind this, so, here goes:
4242

43-
Assuming we take the method called _**rename**_, which takes the required argument **mapper**, as well as, an optional configuration argument. In pre-v1 version of Danfojs, the function signature is as follows:
43+
Assuming we take the method called _**rename**_, which takes required object mapper, as well as, optional configuration argument. In pre-v1 version of Danfojs, the function signature is as follows:
4444

4545
```
4646
rename( { mapper, axis, inplace } ) => DataFrame

0 commit comments

Comments
 (0)