Inconsistencies with newlines
mwang25277 opened this issue · comments
Attached is a csv file generated using jsonexport to convert Twitter data (100 tweets) from the Streaming API (in JSON) to the given csv file.
`twitStream.on('tweet', function(tweet) {
counter++;
tweets.push(tweet);
if(counter == count) {
twitStream.stop();
var parsedTweets = [];
for(aTweet in tweets) {
var parsed = {
created_at: tweets[aTweet].created_at,
id: tweets[aTweet].id,
text: tweets[aTweet].text,
user_id: tweets[aTweet].user.id,
user_name: tweets[aTweet].user.name,
user_screen_name: tweets[aTweet].user.screen_name,
user_location: tweets[aTweet].user.location,
user_followers_count: tweets[aTweet].user.followers_count,
user_friends_count: tweets[aTweet].user.friends_count,
user_created_at: tweets[aTweet].user.created_at,
user_time_zone: tweets[aTweet].user.time_zone,
user_profile_background_color: tweets[aTweet].user.profile_background_color,
user_profile_image_url: tweets[aTweet].user.profile_image_url,
geo: tweets[aTweet].geo,
coordinates: tweets[aTweet].coordinates,
place: tweets[aTweet].place
}
parsedTweets.push(parsed);
}
//https://www.npmjs.com/package/jsonexport
jsonexport(parsedTweets, function(err, csv) {
if(err) return console.log(err);
fs.writeFile("wangm13-tweets.csv", csv);
});
res.send(tweets);
}
});`
In the csv file, some of the text fields with newlines are correctly surrounded with quotes (for example on line 46: "RT @LToddWood: Judge Napolitano Returns On Fox News, Stands By Claim Brits Spied On Trump
https://t.co/Bumb2HG8eI"). However, some are not.
Examples:
Line 6
RT @TLBJames: This is EXACTLY the bigoted-GOP-emboldening I knew Trump's coup-by-EC-victory would cause.
And EXACTLY why we're g…
Line 35
Please stop this.
cc @SenMarkey @SenWarren @RepKClark https://t.co/LStc6p6TmW
@mwang25277 This should be fixed in v2.0.0, i will close the issue after it's published.