Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updating to file

  • Loading branch information...
commit a217621d1c9858f6519c438472f6a49ba27d4eaa 1 parent d7f1d63
Jenn authored
Showing with 16 additions and 7 deletions.
  1. +16 −7 twitter/twitterStatus.rb
View
23 twitter/twitterStatus.rb
@@ -8,7 +8,8 @@
tweet_ids = Array.new
#filename to save CSV
-fileout = File.new("twitter_flisol2011-2012.csv", "w")
+fileout = File.open("twitter_flisol2011-2012.csv", "w")
+
filein = File.open("idsflisol2012.txt");
#saving ID's tweets
@@ -36,13 +37,13 @@ def addquote(word)
save = ["id", "source" ];
save_user = ["screen_name", "location","followers_count", "friends_count", "listed_count", "time_zone","lang"]
-save_list = Array.new
#header CSV
-header = 'id; text; source; screen_name; location; followers_count; friends_count; listed_count; time_zone; lang'
+header = 'id; source; screen_name; location; followers_count; friends_count; listed_count; time_zone; lang'
+save_list = Array.new
#writing header in file
-fileout.puts header
+fileout.write(header)
#search all id's info in twitter
tweet_ids.each do |val|
@@ -50,19 +51,27 @@ def addquote(word)
begin
tweet = Twitter.status(val, {include_entities: "1"})
sleep(5)
- #saving
+ #saving
save.each do |val|
save_list.push(addquote(tweet[val].to_s().gsub('\n', '').chomp))
end
save_user.each do |val|
- save_list.push(addquote(tweet["user"][val].to_s().gsub('\n', '')))
+ save_list.push(addquote(tweet["user"][val].to_s().gsub('\n', '').chomp))
end
line = save_list.join(';')
- fileout.puts line
+
+ line = line + "\n"
+
+ print line
+
+ fileout.write(line)
+
+ save_list.clear()
rescue Exception => msg
puts "#{msg} id #{val}"
end
end
+fileout.close();
Please sign in to comment.
Something went wrong with that request. Please try again.