I have an array called property_details_array where each line of the array looks like:
["\n \n \n \n 1 W Maple Dr,\n Atlanta,\n GA\n 30315"
I'm trying to figure out the best way to clean the data for output into a table-like format, either CSV or HTML.
There are over 200 lines for each of these arrays so automating this would be extremely helpful. I started by parsing the data like:
property_details_array.each do |i|
prop_info = i.split("\n")
street = prop_info[4].strip
city = prop_info[5].strip
state = prop_info[6].strip
zip = prop_info[7].strip
end
However, I'm kind of stuck on where to go next. I've been thinking of either doing it as an array of arrays or an array of hashes, but I'm not sure if one is better than the other based on how much data I would be working with. Both methods seem to make sense, however since I'm having to clean up the data first, I'm not sure on the best way to go about it.
How do I best feed in these values for future output?
New Info
@tadman - Sorry for the lack of explanation and thank you very much for your help. What I meant to say was, After looking at the data closer, I realized the results are not in a predictable order. Sometimes price will be at [16], other times it's not. I'm back to the drawing board on trying to figure out how to get results into an array of hashes.
The raw data I'm working with looks like:
["\n \n \n \n 2265 Tanglewood Cir NE,\n Atlanta,\n GA\n 30345\n \n \n\n \n Dresden East\n \n \n\n $289,900\n \n \n \n 3 bd\n 2 ba\n 1,566 sq ft\n
0.3 acres lot\n \n \n \n \n Single Family Home\n \n \n \n \n
Brokered by Re/Max Town And Country\n \n \n
\n \n \n Brokered by \n Re/Max
Town And Country\n \n \n \n ", "\n \n
\n \n 2141 Dunwoody Gln,\n
Atlanta,\n GA\n 30338\n \n \n\n
\n \n $469,900\n \n \n
\n 4 bd\n 3 ba\n 2,850 sq
ft\n 0.3 acres lot\n 2 car\n
\n \n \n \n Single Family Home\n
\n \n \n \n Brokered by
Buckhead Home Realty Llc\n \n \n \n
\n \n Brokered by \n Buckhead Home
Realty Llc\n \n \n \n ", "\n \n
\n \n 1048 Martin St SE,\n
Atlanta,\n GA\n 30315\n \n \n\n
\n Intown South\n Peoplestown\n \n \n
\n $164,900\n \n \n \n
5 bd\n 3 ba\n 2,376 sq ft\n
7,405 sq ft lot\n \n \n \n \n
Single Family Home\n \n \n \n \n
Brokered by Greenlet Llc\n \n \n \n
\n \n Brokered by \n Greenlet Llc\n
\n \n \n ", "\n \n \n \n
1048 Martin St SE,\n Atlanta,\n GA\n
30315\n \n \n\n \n Intown South\n
Peoplestown\n \n \n \n $164,900\n
\n \n \n 5 bd\n 3
ba\n 2,055 sq ft\n 7,584 sq ft lot\n
\n \n \n \n Single Family Home\n
\n \n \n \n Brokered by
Greenlet, Llc\n \n \n \n \n
\n Brokered by \n Greenlet, Llc\n \n
\n \n "]
Ideally, I'm trying to parse out the following: (Street, City, State, Zip, Price, BD, BA, Sq.FT) Any ideas on the best way to do this.