# Loading multiple csv files and adding fields on to an existing table by finding the id

**URL:** <https://www.ruby-forum.com/t/loading-multiple-csv-files-and-adding-fields-on-to-an-existing-table-by-finding-the-id/116815>\
**Category:** Rails\
**Created:** [October 10, 2007, 12:42am UTC](https://www.ruby-forum.com/t/loading-multiple-csv-files-and-adding-fields-on-to-an-existing-table-by-finding-the-id/116815 "2007-10-10T00:42:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vicky](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b19c9b/32.png) [@vicky](https://www.ruby-forum.com/u/vicky)\
**Post date:** [October 10, 2007, 12:42am UTC](https://www.ruby-forum.com/t/loading-multiple-csv-files-and-adding-fields-on-to-an-existing-table-by-finding-the-id/116815/1 "2007-10-10T00:42:01Z")

</div>

There are many, many files. These files are all in text files and I  
have been successfully using ‘FasterCSV’ but there are so many files.  
What would be the way to

1. Schools Table exists  
id 1  
sch\_id 0998711  
name Cudahy H.S.  
address 1411 S. 21st  
city Cudahy  
state WI  
zip 53110

In a separate file: school id, email address, latitude coord.,  
longitude coord., total num enrollment, total num teachers

How would I go about adding the other values to the pre-existing  
table? Could I do this through ROR? If yes, how would I code that to  
work with FasterCSV?

1. The second question is about the grades and years. If there are  
files like

Sch\_id Grade Year Math-Adv Math-Prof. Math-Basic Math-  
Min  
Sample file 1: 0998711 grade 3 2007 40  
8 24 6 2 5 9 4  
Sample file 2: 0998711 grade 6 2004 55  
12 28 8 7 10 3 3  
Sample file 3: 0000022 grade 7 2002

Would it be best to create a Grade\_Year table for each one, (ie  
GR03\_2007, GR06\_2004) or to have a GR03, GR04 and then put the year as  
a field in the table? Or should I create a table with all the results  
for that school

Table: 0998711\_Scores  
2007 field Year  
Gr03 , field Grade,  
40  
8

Would I be better off just loading this data into MySQL and not  
through migrations?

1. If I could concatonate the table name with the key to the school  
(see above 0998711\_Scores) would this be a bad idea? Or to really  
concatonate it even more like (0998711\_Gr03\_2007).

Does anyone have any great ideas on how I should go about doing this?

Thanks.
