similar to: Help wrtiting test for models that use CSV data

Displaying 20 results from an estimated 40000 matches similar to: "Help wrtiting test for models that use CSV data"

2008 Apr 09
3
help with model relationship for Product/Bill of Materials
I am struggling to find the best way to set up relationships to achieve this so that it fits the rails idioms. I have a table of products and I want to be able to create a bill of materials for a product.. So a product can either be a single item, or a package consisting of several other products. I have created a table: ---- class BomItem < ActiveRecord::Base belongs_to :product
2005 Apr 27
1
Data() and CSV files
Hello, For reasons I don't understand, data() imports CSV (Comma-Separated Values) as if they were delimited by semicolons instead of commas. (Are semicolon-separated Comma-Separated-Value files common somewhere?) Given that this is the case, if I choose to put comma-delimited CSV files in my data directory, what is the preferred method of loading these into memory?
2012 Feb 13
4
Reading in csv with footer
Hi, I have a CSV file that is formatted well, except that the last line is a "summary" not is CSV format. Toy example: label_1, label_2, label_3 1,2,3 3,2,4 2,3,4 Total Rows: 3 When I try to import this into R with: d <- read.table("foo.csv", header=T, sep=",") It fails to import properly because of the last line. Currently, I have a shell script that strips
2010 Oct 21
3
importing csv gets me all 16,000 columns with "NA"
I'm new to R. I have a mac (OS10.6). I have converted an Excel file to a csv to import into R. I have used many methods to import the file, most do not work, the best so far is: filename <- read.csv(/Users/Desktop/csvfile.csv", header=T, sep=","). I have also tried taking out the header and sep lines and it still imports fine. Regardless of what I do, it always brings in
2006 Nov 22
1
Polymorphic Data Modelling Question
Hello, I am not sure of the best way to model this situation in Rails and would appreciate some guidance. An order can hold multiple line items. Each line item is for a certain number of any given product. There are four products, each in a different table because they have completely different attributes. So I have: Order - has many LineItems LineItem - belongs to an Order
2007 Dec 20
0
Data bug that read.csv doesn't like
Hello, I have a bug in my data that read.csv doesn't like, but _only_ when specifying "na.strings = 'missing'". If I delete the offending Chinese characters the problem goes away as well. I'm satisfied that the problems with this data file are fixed, but is there anything I can to do avoid this in the future (other than avoiding Chinese characters). Any ideas as
2006 Jul 21
1
How to dynamically add more rows and submit data
Let''s assume that I am trying to build an application where the user can enter invoice. In the app the user can add lines items. Each line item has decription, date, rate and hours. When the invoice screen comes up the first time I have one blank row for the line items. <tr> <th>Description</th> <th>Date</th>
2006 Feb 06
4
Memory Issue while looping through CSV file
I have a site on a shared host at TextDrive. I have an import process that imports a CSV file into the database using a ruby script executed using script/runner. TextDrive has a memory limit which I am hitting and the process gets killed. I get through to about 400 records before it dies. I guess each time I instantate a new object for each record I am using more memory but thought I was using
2012 Feb 17
1
incomplete final line found by readTableHeader on 'test.csv'
Hello, I have recently had issues with read.csv where i get the following warning, and this happens on both my OSX and Linux machines. Here is the warning and an example CSV file is attached: Warning message: In read.table(file = file, header = header, sep = sep, quote = quote, : incomplete final line found by readTableHeader on 'test.csv' http://
2006 Feb 25
2
Adding header lines to a dataframe that is exported using write.csv
I would like to export a dataframe to a .csv using: >write.csv(dataframe,"dataframe.csv") but I need to add four "header" lines to the csv that are not part of the dataframe (which itself has a line of column headers). The difficulty (for me, at least!) lies in the requirement that certain elements of the header (X, Y and the number of "Q"s - please see example
2006 Feb 22
0
Problem: Null values in a CSV format fixture show up a 0 in the test database
Hi all, I''m running into a strange problem. I''m trying to get null values to load from a fixture in CSV form into my test database, but they show up as 0 (zero). I have a table people (simplified version below) create table people ( id int not null auto_increment, target int null default null, name varchar(50) not null, primary key(id) ); that has a
2009 Sep 22
6
Import excel / csv files
Hey, What way is the best to do imports of CSV files?
2007 Jan 29
3
rsync: mkstemp "/20070129_1012/.status.csv.IWS933" (in test) failed: No such file or directory (2)
Hi, --- + rsync -av --timeout 120 /home/20070129_1012/status.csv --port 5873 fileserver::test/20070129_1012/status.csv building file list ... done status.csv rsync: mkstemp "/20070129_1012/.status.csv.IWS933" (in test) failed: No such file or directory (2) sent 347 bytes received 38 bytes 770.00 bytes/sec total size is 228 speedup is 0.59 rsync error: some files could not be
2007 Aug 07
0
has_and_belongs_to_many polymorphic question
I''ve got a situation where I''m trying to model the following relationship: a ''page'' has multiple lineitems a ''lineitem'' can be either a ''page'' or a ''entity'' The ''lineitem'' looks like it should be polymorphic but the ''page'' and ''lineitem''
2006 Jul 17
1
Updating multiple children from one page
Hello, I have a model called invoice and one called lineitem. An invoice has_many lineitems, and an lineitem belongs to an invoice. I have a model method that calculates the price of a lineitem, and one that calculates all lineitems in an invoice. I want to have an edit page that lists all the invoices lineitems and their calculated prices, with a text field for a person to change the
2013 Sep 23
1
redirect on browser success, but redirect on functional test is error
line_items.yml: one: product_id: 1 cart_id: 1 quantity: 1 carts.yml: one: {} product.rb: has_many :line_items cart.rb: has_many :line_items, dependent: :destroy line_item.rb: belongs_to :product belongs_to :cart line_item_controller.rb: def destroy @line_item = LineItem.find(params[:id]) @cart = @line_item.cart @line_item.destroy respond_to do |format| format.html
2010 Oct 29
1
Updating asteriskcdrdb with uniqueid field from Master.csv, Master.csv.1....Master.csv.5 - Must I bring all files together first?
Hi Everyone, Just noted that PBXinaFLASH failed me again on yet something else. The uniqueid field didn't update on the asteriskcdrdb in the past few months but it is available in the .csv files in /var/log/asterisk/cdr-csv/*.csv I have already re-did the asterisk-addons install with correct parameters to include future calls "uniqueid" in the table (I have no clue why these
2012 Sep 26
1
Ask for help - how to change WHIRR.117.csv to WHIRR_117.csv
Hi, I have a script below. dat <- read.table(file="pt.csv", header=T, sep=",", row.names=1, col.names=1) dat for(which_col in seq_len(ncol(dat))) { subset_data <- dat[,which_col:ncol(dat)] file_name <- sprintf('%s.csv', colnames(dat)[which_col]) write.csv(subset_data, file_name) message(sprintf('Saving %s', file_name)) }
2011 Jan 13
1
Unexpected behaviour of write.csv - read.csv
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Assuming the following: > x <- data.frame(a=1:10, b=runif(10)) > str(x) 'data.frame': 10 obs. of 2 variables: $ a: int 1 2 3 4 5 6 7 8 9 10 $ b: num 0.692 0.325 0.634 0.16 0.873 ... > write.csv(x, "x.csv") > x2 <- read.csv("x.csv") > str(x2) 'data.frame': 10 obs. of 3 variables: $ X:
2006 Feb 16
9
association not inserted automatically.
Hello, I am trying to write a sample application. I have class LineItem< ActiveRecord::Base belongs_to : order end && class Order < ActiveRecord::Base has_one :line_item end Now in the controller i am trying : def add @ord = Order.new(params[:ord]) @ord.line_item = LineItem.new(params[:lineitem]) if @ord.save redirect_to :action => ''list'' else render