data_set.txt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. $table->string('copyright_detail_code')->nullable();
  2. $table->string('zip_code')->nullable();
  3. $table->string('update_key_no')->nullable();
  4. $table->string('action_code')->nullable();
  5. $table->string('record_type_code')->nullable();
  6. $table->string('carrier_route_id')->nullable();
  7. $table->string('street_pre_drctn_abbrev')->nullable();
  8. $table->string('street_name')->nullable();
  9. $table->string('street_suffix_abbrev')->nullable();
  10. $table->string('street_post_drctn_abbrev')->nullable();
  11. $table->string('addr_primary_low_no')->nullable();
  12. $table->string('addr_primary_high_no')->nullable();
  13. $table->string('addr_prmry_odd_even_code')->nullable();
  14. $table->string('building_or_firm_name')->nullable();
  15. $table->string('addr_secondary_abbrev')->nullable();
  16. $table->string('addr_secondary_low_no')->nullable();
  17. $table->string('addr_secondary_high_no')->nullable();
  18. $table->string('addr_secny_odd_even_code')->nullable();
  19. $table->string('low_no_zip_sector_no')->nullable();
  20. $table->string('low_no_zip_segment_no')->nullable();
  21. $table->string('high_no_zip_sector_no')->nullable();
  22. $table->string('high_no_zip_segment_no')->nullable();
  23. $table->string('base_alt_code')->nullable();
  24. $table->string('lacs_status_ind')->nullable();
  25. $table->string('govt_bldg_ind')->nullable();
  26. $table->string('finance_no')->nullable();
  27. $table->string('stusps')->nullable();
  28. $table->string('countyfp')->nullable();
  29. $table->string('congressional_dist_no')->nullable();
  30. $table->string('muncipality_ctyst_key')->nullable();
  31. $table->string('urbanization_ctyst_key')->nullable();
  32. $table->string('prefd_last_line_ctyst_key)->nullable();
  33. $positions = [
  34. [1,1,'copyright_detail_code'],
  35. [2,5,'zip_code'],
  36. [7,10,'update_key_no'],
  37. [17,1,'action_code'],
  38. [18,1,'record_type_code'],
  39. [19,4,'carrier_route_id'],
  40. [23,2,'street_pre_drctn_abbrev'],
  41. [25,28,'street_name'],
  42. [53,4,'street_suffix_abbrev'],
  43. [57,2,'street_post_drctn_abbrev'],
  44. [59,10,'addr_primary_low_no'],
  45. [69,10,'addr_primary_high_no'],
  46. [79,1,'addr_prmry_odd_even_code'],
  47. [80,40,'building_or_firm_name'],
  48. [120,4,'addr_secondary_abbrev'],
  49. [124,8,'addr_secondary_low_no'],
  50. [132,8,'addr_secondary_high_no'],
  51. [140,1,'addr_secny_odd_even_code'],
  52. [141,2,'low_no_zip_sector_no'],
  53. [143,2,'low_no_zip_segment_no'],
  54. [145,2,'high_no_zip_sector_no'],
  55. [147,2,'high_no_zip_segment_no'],
  56. [149,1,'base_alt_code'],
  57. [150,1,'lacs_status_ind'],
  58. [151,1,'govt_bldg_ind'],
  59. [152,6,'finance_no'],
  60. [158,2,'stusps'],
  61. [160,3,'countyfp'],
  62. [163,2,'congressional_dist_no'],
  63. [165,6,'muncipality_ctyst_key'],
  64. [171,6,'urbanization_ctyst_key'],
  65. [177,6,'prefd_last_line_ctyst_key]'
  66. ];
  67. $filePath = '/home/josh/output.txt';
  68. $handle = fopen($filePath, "r") or die("Couldn't get handle");
  69. if ($handle) {
  70. while (!feof($handle)) {
  71. $buffer = fgets($handle, 4096);
  72. $row = new Zip4Row();
  73. foreach($positions as $position){
  74. $row->{$position[2]} = substr($l, $position[0], $position[1]);
  75. }
  76. $row->save();
  77. }
  78. fclose($handle);
  79. }