javascript - Multiple CSV files to PHP Array - -


i have problems csv files. have 50 csv files, looks same below.

i need import them php array - (later put them js var, , use in diagrams) csv dont looks should (i cant change it) - have data @ top (first 10 lines) - need use them in different places (just show them - "kategoria:";"rolnictwo, leŚnictwo Łowiectwo"; - title)

"okres sprawozdawczy:";"dane roczne"; "kategoria:";"rolnictwo, leŚnictwo Łowiectwo"; "grupa:";"skup produktÓw rolnych"; "podgrupa:";"skup produktów na 1 ha użytków rolnych"; "wymiary:";"wykaz produktów, lata";  "kod";"jednostka terytorialna";"buraki cukrowe";"buraki cukrowe";"buraki cukrowe";"buraki cukrowe"; "2010";"2011";"2012";"2013"; "[kg]";"[kg]";"[kg]";"[kg]"; "1100000000";" ŁÓdzkie";"278";"355";"363";"333"; "1140000000";" mazowieckie";"247";"250";"286";"348"; "2120000000";" maŁopolskie";"67";"87";"114";"127"; "2240000000";" ŚlĄskie";"168";"218";"245";"281"; "3060000000";" lubelskie";"1139";"1170";"1235";"1346"; "3180000000";" podkarpackie";"249";"208";"342";"404"; "3200000000";" podlaskie";"6";"30";"5";"0"; "3260000000";" ŚwiĘtokrzyskie";"479";"482";"337";"534"; "4080000000";" lubuskie";"184";"141";"264";"229"; "4300000000";" wielkopolskie";"1102";"1412";"1485";"1532"; "4320000000";" zachodniopomorskie";"522";"830";"909";"642"; "5020000000";" dolnoŚlĄskie";"1044";"1045";"1274";"1136"; "5160000000";" opolskie";"1392";"1386";"2113";"1660"; "6040000000";" kujawsko-pomorskie";"1588";"2040";"2272";"2252"; "6220000000";" pomorskie";"624";"748";"724";"879"; "6280000000";" warmiŃsko-mazurskie";"153";"150";"163";"167"; 

how can print them array - looks this:

[0] => array       (       [0] okres sprawozdawczy       [1] dane roczne       ) [1] => array       (       [0] kategoria       [1] rolnictwo, leŚnictwo Łowiectwo       ) [2] => array       (       [0] grupa:       [1] skup produktÓw rolnych       ) 

etc. first 5 lines of csv lines.

but later line 7 (6 empty) - line 7,8,9 1 header..

"kod" - "1100000000" "jednostka terytorialna" - "ŁÓdzkie"  "buraki cukrowe","2010","[kg]" - "278" "buraki cukrowe","2011","[kg]" - "355" "buraki cukrowe","2012","[kg]" - "363" "buraki cukrowe","2013","[kg]" - "333" 
  • 3 headers 1 data, need think that:
[6] => array ([0] buraki cukrowe => array ([0] 2010 => array ([0] kg => array ([0] 278)

where "278" data need use , put in js var. im not sure way this, please me out..

first set file on variable, can use file_get_content() this

$csvdata = file_get_contents('your_file.csv'); 

you can files need add

after have $csvdata have explode , chunk this

$explodedcsvdata = explode(';',$csvdata); $chuckedcsvdata = array_chunk($explodedcsvdata,2); 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -