rubyzip

Stream and unzip large csv file with ruby

做~自己de王妃 提交于 2020-05-25 04:56:40
问题 I have problem where I need to download, unzip, and then process line by line a very large CSV file. I think it's useful to give you an idea how large the file is: big_file.zip ~700mb big_file.csv ~23gb Here's some things I'd like to happen: Don't have to download the whole file before unzipping Don't have to unzip whole file before parsing csv lines Don't use up very much memory/disk while doing all this I don't know if that's possible or not. Here's what I was thinking: require 'open-uri'

Stream and unzip large csv file with ruby

北城余情 提交于 2020-05-25 04:56:13
问题 I have problem where I need to download, unzip, and then process line by line a very large CSV file. I think it's useful to give you an idea how large the file is: big_file.zip ~700mb big_file.csv ~23gb Here's some things I'd like to happen: Don't have to download the whole file before unzipping Don't have to unzip whole file before parsing csv lines Don't use up very much memory/disk while doing all this I don't know if that's possible or not. Here's what I was thinking: require 'open-uri'

Ruby: Download zip file and extract

谁说胖子不能爱 提交于 2020-02-27 23:30:14
问题 I have a ruby script that downloads a remote ZIP file from a server using rubys open command. When I look into the downloaded content, it shows something like this: PK\x03\x04\x14\x00\b\x00\b\x00\x9B\x84PG\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\x00\x10\x00foobar.txtUX\f\x00\x86\v!V\x85\v!V\xF6\x01\x14\x00K\xCB\xCFOJ,RH\x03S\\\x00PK\a\b\xC1\xC0\x1F\xE8\f\x00\x00\x00\x0E\x00\x00\x00PK\x01\x02\x15\x03\x14\x00\b\x00\b\x00\x9B\x84PG\xC1\xC0\x1F\xE8\f\x00\x00\x00\x0E\x00\x00\x00\n\x00\f

What zip library works well with Ruby 1.9.2?

∥☆過路亽.° 提交于 2019-12-31 03:35:25
问题 I used the rubyzip gem in Ruby 1.8.7 before, but I heard rubyzip doesn't work well with ruby 1.9.2. What zip libraries work well with Ruby 1.9.2? 回答1: Have you actually tried using rubyzip with 1.9.2? Seems to work fine for me: >> RUBY_VERSION #=> "1.9.2" >> require 'zip/zip' #=> true >> Zip::ZipFile.foreach(File.expand_path("~/Downloads/Archive.zip")) { |f| p f } #=> [bartxt, footxt] bar.txt foo.txt 回答2: I used rubyzip gem in Ruby 1.8.7 also. For Ruby 1.9.x you need to use version 0.9.5 or

Using rubyzip error - no such file to load — zip/zip

流过昼夜 提交于 2019-12-28 06:27:27
问题 I know there is another thread on this subject but I still face this problem even after using all solutions. Is there any other way to generate zip files? Can i use Ubuntu system commands? I did gem install rubyzip I have require 'rubygems' require 'zip/zip' in my controller But i still get the same error - no such file to load -- zip/zip I tried with both ruby 1.8.7 and ruby 1.9.2 with rails 3.0.5 on Ubuntu Could you please help me? Thanks. 回答1: I fixed this problem by specifying gem version

What might explain an “invalid stored block lengths” error?

空扰寡人 提交于 2019-12-12 11:01:52
问题 I am running a Rails (3.2.3) application with Ruby 1.9.3p194 on the basic Ubuntu lucid32 image in a Vagrant virtual box. The virtual box is running on Leopard, for what it's worth. I'm trying to use rubyzip in the application to decompress a zip archive - 2009_da_lmp.zip . Using code directly from examples in the rubyzip repository, I can confirm that I can list the archive file contents: #f is the absolute path to 2009_da_lmp.zip (string) Zip::ZipFile.open(f) { |zf| zf.entries[0] } =>

resource lock while generating the zip using Zipfilegenerator class, Ruby

纵饮孤独 提交于 2019-12-11 08:39:07
问题 I have an applicaiton in angularJS and ruby on rails. I am generating the subfolder and html files through code. Like my folder structure is like that -Root -----Sub1 ----------Sub_Sub1 ----------Sub_Sub2 ----------index.html -----Sub2 -----abc.html I have generated the zip file of the directory through Zipfilegenerator. I have made the functionality so that before generating the directory the system checks if any previous directory exists with the same name then it will delete that and then

Set compression level when generating a ZIP file using RubyZip

瘦欲@ 提交于 2019-12-09 06:24:48
问题 I have a Ruby program that zips a directory tree of XML files using the rubyzip gem. My problem is that the file is starting to be heavy and I would like to increase the compression level, since compression time is not an issue. I could not find in the rubyzip documentation a way to specify the compression level for the created ZIP file. Anyone know how to change this setting? Is there another Ruby library that allows to specify compression level? 回答1: Here is the code I created by looking at

Using rubyzip to add files and nested directories to a zipoutputstream

最后都变了- 提交于 2019-12-09 06:05:43
问题 I'm struggling with getting rubyzip to append directories to a zipoutputstream. (I want the output stream so I can send it from a rails controller). My code follows this example: http://info.michael-simons.eu/2008/01/21/using-rubyzip-to-create-zip-files-on-the-fly/ When modified to include directories in the list of files to add I get the following error: Any help would be greatly appreciated. UPDATE After trying a number of solutions I had best success with zipruby which has a clean api and

Zipping a directory in Rails [closed]

痴心易碎 提交于 2019-12-08 19:33:52
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . How do i go about zipping a directory in ruby on rails? I've tried rubyzip without success. I don't need to zip the contents of the dir individually just zip the dir itself. 回答1: You are going to have to loop