Closed hoffmanc closed 12 years ago
hm, you rake task don't have probably permissions to create temporary files
run it with sudo or clone the repo into home directory
Command failed with status (1): [/usr/bin/ruby1.8 -I"lib:lib:test" "/usr/li...]
I tried sudo, with no success. How do you know it is a permissions issue? status (1)? It is already in my home dir.
oh, and here is a python script that basically does everything you need:
import csv from itertools import izip f = open( 'export.csv', 'r' ) reader = csv.reader( f ) keys = () out = [] for property in reader: if len(keys) == 0: keys = property else: property = iter( property ) data = {} for key in keys: data[ key ] = property.next() out += [ data ] print out
I don't know. I'm not a ruby master :)
Thanks for sharing the python script, The ruby script is not much longer: http://github.com/darwin/csv2json/blob/master/lib/csv2json.rb
I just wrapped it into rubygems for convenient commandline installation.
This issue should now be fixed; tests were failing because the hash used to produce the JSON wasn't sorting the keys the same every time (so comparison with the sample data would fail). Today's commits have fixed this problem.
/usr/bin/ruby1.8 -I"lib:lib:test" "/usr/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake/rake_test_loader.rb" "test/test_csv2json.rb" (in /home/hoffmanc/ocer/darwin-csv2json-0436af7) All dependencies seem to be installed. Loaded suite /usr/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake/rake_test_loader Started population_comma.csv F Finished in 0.024187 seconds.
1) Failure: test: Csv2json should parse some test files. (TestCsv2json) [./test/test_csv2json.rb:18:in
__bind_1269015901_504391' ./test/test_csv2json.rb:12:in
open' ./test/test_csv2json.rb:12:in__bind_1269015901_504391' ./test/test_csv2json.rb:9:in
glob' ./test/test_csv2json.rb:9:in__bind_1269015901_504391' ./test/test_csv2json.rb:8:in
chdir' ./test/test_csv2json.rb:8:in__bind_1269015901_504391' /usr/lib/ruby/gems/1.8/gems/shoulda-2.10.3/lib/shoulda/context.rb:362:in
call' /usr/lib/ruby/gems/1.8/gems/shoulda-2.10.3/lib/shoulda/context.rb:362:in `test: Csv2json should parse some test files. ']: