Skip to content

Commit b5649c4

Browse files
authored
Added csv url example
This took my quite some time to figure out, so i'm adding it to the docs somehow the stream example wasn't clear enough because the old way of writing this (before 1.1.0) was: ```js request.get(url).pipe(csv); ```
1 parent 590d558 commit b5649c4

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

readme.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,23 @@ csv()
111111

112112
```
113113

114+
### From CSV Url
115+
116+
```js
117+
const request=require('request')
118+
const csv=require('csvtojson')
119+
120+
csv()
121+
.fromStream(request.get('http://mywebsite.com/mycsvfile.csv'))
122+
.on('csv',(csvRow)=>{
123+
// csvRow is an array
124+
})
125+
.on('done',(error)=>{
126+
127+
})
128+
129+
```
130+
114131
### Convert to CSV row arrays with csv header row
115132

116133
```js

0 commit comments

Comments
 (0)