icenine

extract_nrls_2.0.0_stable.pl

Jan 1st, 2014
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 19.67 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3. use strict;
  4. use 5.010;
  5.  
  6. # Required for parsing NRLS data
  7. use Excel::Reader::XLSX;
  8. use DateTime::Format::Excel;
  9.  
  10. # Required for inputing data into Neo4j
  11. use REST::Neo4p;
  12.  
  13. use Data::Dumper;
  14. use Getopt::Long;
  15.  
  16. use Try::Tiny;
  17.  
  18. $| = 1;
  19.  
  20. my $input_file;
  21. my $neo_uri = 'http://larva.med.ic.ac.uk:7474';
  22.  
  23. GetOptions (
  24.     "input_file=s"  => \$input_file,
  25.     "neo_uri=s"     => \$neo_uri,);
  26.  
  27. if (!defined($input_file)) {
  28.     die "Usage: $0 --input_file <xlsx file>";
  29. }
  30.  
  31. # Define required column headers
  32. my @required_columns = (
  33.     "IN07",             # Incident description
  34.     "PD09",             # Indident degree of harm
  35.     "RP07",             # NHS Trust
  36.     "IN05_lvl1",        # Incident category
  37.     "PD05_lvl1",        # Speciality
  38.     "PD02",             # Patient sex
  39.     "IN01",             # Incident date
  40.     "IN02_A_01",        # Incident hour
  41.     "Age_at_Incident",  # Patient age
  42.     "PD11",             # Patient ethnicity
  43.     "ST01_LVL1",        # Recorder staff type
  44.     "IN03_lvl1",        # Incident location
  45.     "incidentID",       # Unique incident ID
  46. );
  47.  
  48. my $reader = Excel::Reader::XLSX->new();
  49.  
  50. my $workbook = $reader->read_file($input_file) or
  51.     die ("Could not read $input_file.");
  52.  
  53. my $worksheet = ($workbook->worksheets())[0] or
  54.     die ("Failed to assign worksheet from workbook.");
  55.  
  56. my $column_header_row = $worksheet->next_row() or
  57.     die ("Could not get column header row.");
  58.  
  59. my %header_map;
  60.  
  61. # Find column positions for required columns
  62. while (my $cell = $column_header_row->next_cell()) {
  63.     my $cell_value = $cell->value();
  64.  
  65.     if (grep /$cell_value/, @required_columns) {
  66.         $header_map{$cell_value} = $cell->col();
  67.     }
  68. }
  69.  
  70. # Create connection to Neo4j
  71. REST::Neo4p->connect($neo_uri) or
  72.     die ("Could not connect to $neo_uri.");
  73.  
  74. # Create queries
  75.  
  76. # Create NHS Trust
  77. my $create_nhs_trust_cql =<<'EOCQL';
  78. MATCH (ndt:NRLS_DATA_TYPE)
  79. WHERE
  80. ndt.code = {code}
  81. CREATE UNIQUE
  82. (n:NHS_TRUST { name : {name} })-[:HAS_NRLS_DATA_TYPE]->(ndt)
  83. RETURN n
  84. EOCQL
  85.  
  86. my $create_nhs_trust_query = REST::Neo4p::Query->new($create_nhs_trust_cql)
  87.     or die ("Could not create query for : $create_nhs_trust_cql");
  88.  
  89. # Create NHS Trust Location
  90. my $create_nhs_trust_location_cql =<<'EOCQL';
  91. MERGE (ntl:NHS_TRUST_LOCATION{ location_level_01 : { location_level_01 } })
  92. RETURN ntl;
  93. EOCQL
  94.  
  95. my $create_nhs_trust_location_query =
  96.     REST::Neo4p::Query->new($create_nhs_trust_location_cql)
  97.     or die ("Could not create query for : $create_nhs_trust_location_cql");
  98.  
  99. # Create NHS Trust/NHS Trust Location relationship
  100. my $create_nhs_trust_location_rel_cql =<<'EOCQL';
  101. MATCH (nt:NHS_TRUST), (ntl:NHS_TRUST_LOCATION)
  102. WHERE nt.name = { name }
  103. AND ntl.location_level_01 = { location_level_01 }
  104. CREATE UNIQUE
  105. (ntl)<-[hntl:HAS_NHS_TRUST_LOCATION]-nt RETURN hntl
  106. EOCQL
  107.    
  108. my $create_nhs_trust_location_rel_query =
  109.     REST::Neo4p::Query->new($create_nhs_trust_location_rel_cql)
  110.     or die ("Could not create query for : $create_nhs_trust_location_rel_cql");
  111.  
  112. # Create Incident
  113. my $create_incident_cql =<<'EOCQL';
  114. MERGE (i:INCIDENT { incident_id : { incident_id } })
  115. ON CREATE SET i.incident_timestamp = { incident_timestamp },
  116. i.incident_description = { incident_description }
  117. RETURN i
  118. EOCQL
  119.  
  120. my $create_incident_query =
  121.     REST::Neo4p::Query->new($create_incident_cql)
  122.     or die ("Could not create query for : $create_incident_cql");
  123.  
  124. # Create Incident/NRLS Data Type relationship
  125. my $create_incident_ndt_rel_cql =<<'EOCQL';
  126. MATCH (i:INCIDENT), (ndt:NRLS_DATA_TYPE)
  127. WHERE i.incident_id = { incident_id }
  128. AND ndt.code = { code }
  129. CREATE UNIQUE
  130. (i)-[hndt:HAS_NRLS_DATA_TYPE]->ndt
  131. RETURN hndt
  132. EOCQL
  133.  
  134. my $create_incident_ndt_rel_query =
  135.     REST::Neo4p::Query->new($create_incident_ndt_rel_cql)
  136.     or die ("Could not create query for : $create_incident_ndt_rel_cql");
  137.  
  138. # Create Incident/NHS Trust relationship
  139. my $create_incident_nhs_trust_rel_cql =<<'EOCQL';
  140. MATCH (n:NHS_TRUST), (i:INCIDENT)
  141. WHERE n.name = { name }
  142. AND i.incident_id = { incident_id }
  143. CREATE UNIQUE
  144. i-[r:IS_NHS_TRUST_INCIDENT]->n
  145. RETURN r
  146. EOCQL
  147.  
  148. my $create_incident_nhs_trust_rel_query =
  149.     REST::Neo4p::Query->new($create_incident_nhs_trust_rel_cql)
  150.     or die ("Could not create query for : $create_incident_nhs_trust_rel_cql");
  151.  
  152. # Create Incident/NHS Trust Location relationship
  153. my $create_incident_ntl_rel_cql =<<'EOCQL';
  154. MATCH (ntl:NHS_TRUST_LOCATION), (i:INCIDENT)
  155. WHERE ntl.location_level_01 = { location_level_01 }
  156. AND i.incident_id = { incident_id }
  157. CREATE UNIQUE
  158. i-[r:IS_NHS_TRUST_LOCATION_INCIDENT]->ntl
  159. RETURN r
  160. EOCQL
  161.  
  162. my $create_incident_ntl_rel_query =
  163.     REST::Neo4p::Query->new($create_incident_ntl_rel_cql)
  164.     or die ("Could not create query for : $create_incident_ntl_rel_cql");
  165.  
  166. # Create Incident Category
  167. my $create_incident_category_cql =<<'EOCQL';
  168. MATCH (ndt:NRLS_DATA_TYPE)
  169. WHERE ndt.code = { code }
  170. CREATE UNIQUE
  171. (ic:INCIDENT_CATEGORY { category_level_01 : { category_level_01 }
  172. })-[:HAS_NRLS_DATA_TYPE]->ndt
  173. RETURN ic
  174. EOCQL
  175.  
  176. my $create_incident_category_query =
  177.     REST::Neo4p::Query->new($create_incident_category_cql)
  178.     or die ("Could not create query for : $create_incident_category_cql");
  179.  
  180. # Create Incident/Incident Category relationship    
  181. my $create_incident_category_rel_cql =<<'EOCQL';
  182. MATCH (i:INCIDENT), (ic:INCIDENT_CATEGORY)
  183. WHERE i.incident_id = { incident_id }
  184. AND ic.category_level_01 = { category_level_01 }
  185. CREATE UNIQUE
  186. ic<-[r:HAS_INCIDENT_CATEGORY]-i
  187. RETURN r
  188. EOCQL
  189.  
  190. my $create_incident_category_rel_query =
  191.     REST::Neo4p::Query->new($create_incident_category_rel_cql)
  192.     or die ("Could not create query for : $create_incident_category_rel_cql");
  193.  
  194. # Create Incident Speciality
  195. my $create_incident_speciality_cql =<<'EOCQL';
  196. MATCH (ndt:NRLS_DATA_TYPE)
  197. WHERE ndt.code = { code }
  198. CREATE UNIQUE
  199. (is:INCIDENT_SPECIALITY { speciality_level_01 : { speciality_level_01 }
  200. })-[:HAS_NRLS_DATA_TYPE]->ndt
  201. RETURN is
  202. EOCQL
  203.  
  204. my $create_incident_speciality_query =
  205.     REST::Neo4p::Query->new($create_incident_speciality_cql)
  206.     or die ("Could not create query for : $create_incident_speciality_cql");
  207.  
  208. # Create Incident/Incident Speciality relationship  
  209. my $create_incident_speciality_rel_cql =<<'EOCQL';
  210. MATCH (i:INCIDENT), (is:INCIDENT_SPECIALITY)
  211. WHERE i.incident_id = { incident_id }
  212. AND is.speciality_level_01 = { speciality_level_01 }
  213. CREATE UNIQUE
  214. is<-[r:HAS_INCIDENT_SPECIALITY]-i
  215. RETURN r
  216. EOCQL
  217.  
  218. my $create_incident_speciality_rel_query =
  219.     REST::Neo4p::Query->new($create_incident_speciality_rel_cql)
  220.     or die ("Could not create query for : $create_incident_speciality_rel_cql");
  221.  
  222. # Create Incident Reporter
  223. my $create_incident_reporter_cql =<<'EOCQL';
  224. MATCH (ndt:NRLS_DATA_TYPE)
  225. WHERE ndt.code = { code }
  226. CREATE UNIQUE
  227. (ir:INCIDENT_REPORTER { reporter_level_01 : { reporter_level_01 }
  228. })-[:HAS_NRLS_DATA_TYPE]->ndt
  229. RETURN ir
  230. EOCQL
  231.  
  232. my $create_incident_reporter_query =
  233.     REST::Neo4p::Query->new($create_incident_reporter_cql)
  234.     or die ("Could not create query for : $create_incident_reporter_cql");
  235.  
  236. # Create Incident/Incident Reporter relationship  
  237. my $create_incident_reporter_rel_cql =<<'EOCQL';
  238. MATCH (i:INCIDENT), (ir:INCIDENT_REPORTER)
  239. WHERE i.incident_id = { incident_id }
  240. AND ir.reporter_level_01 = { reporter_level_01 }
  241. CREATE UNIQUE
  242. ir<-[r:HAS_INCIDENT_REPORTER]-i
  243. RETURN r
  244. EOCQL
  245.  
  246. my $create_incident_reporter_rel_query =
  247.     REST::Neo4p::Query->new($create_incident_reporter_rel_cql)
  248.     or die ("Could not create query for : $create_incident_reporter_rel_cql");
  249.  
  250. # Create Incident Patient
  251. my $create_incident_patient_cql =<<'EOCQL';
  252. MATCH (ndt:NRLS_DATA_TYPE)
  253. WHERE ndt.code = { code }
  254. CREATE UNIQUE
  255. (p:PATIENT {
  256. patient_age : { patient_age },
  257. patient_sex : { patient_sex },
  258. patient_ethnicity : { patient_ethnicity }
  259. })-[:HAS_NRLS_DATA_TYPE]->ndt
  260. RETURN p
  261. EOCQL
  262.  
  263. my $create_incident_patient_query =
  264.     REST::Neo4p::Query->new($create_incident_patient_cql)
  265.     or die ("Could not create query for : $create_incident_patient_cql");
  266.  
  267. # Create Incident/Incident Patient relationship  
  268. my $create_incident_patient_rel_cql =<<'EOCQL';
  269. MATCH (i:INCIDENT), (p:PATIENT)
  270. WHERE i.incident_id = { incident_id }
  271. AND p.patient_age = { patient_age }
  272. AND p.patient_sex = { patient_sex }
  273. AND p.patient_ethnicity = { patient_ethnicity }
  274. CREATE UNIQUE
  275. p<-[r:HAS_INCIDENT_PATIENT]-i
  276. RETURN r
  277. EOCQL
  278.  
  279. my $create_incident_patient_rel_query =
  280.     REST::Neo4p::Query->new($create_incident_patient_rel_cql)
  281.     or die ("Could not create query for : $create_incident_patient_rel_cql");
  282.  
  283. # Create Degree Of Harm
  284. my $create_incident_doh_cql =<<'EOCQL';
  285. MATCH (ndt:NRLS_DATA_TYPE) WHERE ndt.code = { code }
  286. CREATE UNIQUE
  287. (doh:DEGREE_OF_HARM { degree_of_harm : { degree_of_harm }
  288. })-[:HAS_NRLS_DATA_TYPE]->ndt RETURN doh
  289. EOCQL
  290.  
  291. my $create_incident_doh_query =
  292.     REST::Neo4p::Query->new($create_incident_doh_cql)
  293.     or die ("Could not create query for : $create_incident_doh_cql");
  294.  
  295. # Create Incident/Degree Of Harm relationship
  296. my $create_incident_doh_rel_cql =<<'EOCQL';
  297. MATCH (i:INCIDENT), (doh:DEGREE_OF_HARM)
  298. WHERE i.incident_id = { incident_id }
  299. AND doh.degree_of_harm = { degree_of_harm }
  300. CREATE UNIQUE
  301. doh<-[r:HAS_INCIDENT_DEGREE_OF_HARM]-i RETURN r
  302. EOCQL
  303.  
  304. my $create_incident_doh_rel_query =
  305.     REST::Neo4p::Query->new($create_incident_doh_rel_cql)
  306.     or die ("Could not create query for : $create_incident_doh_rel_cql");
  307.  
  308. # Place holders
  309. my (%nodes, %relationships, %created_nhs_trust_location);
  310.  
  311. my $created_nhs_trust_node;
  312.  
  313. while (my $row = $worksheet->next_row) {
  314.     my @values = $row->values();
  315.     if (@values == 0) {
  316.         warn ("Row at ", $row->row_number() , " contains no values.");
  317.     }
  318.  
  319.     @values = map {
  320.         if ($_ =~ /^ ?$/ or !defined($_)) {
  321.             $_ = "NOT_DEFINED";
  322.         } else {
  323.             $_;
  324.         }
  325.     } @values;
  326.  
  327.     my ($nhs_trust, $nhs_trust_location, $degree_of_harm,
  328.         $patient_age, $patient_sex, $patient_ethnicity,
  329.         $incident_id, $incident_date,
  330.         $incident_hour, $incident_description,
  331.         $incident_category, $incident_reporter,
  332.         $incident_speciality);
  333.  
  334.     my ($last_known_query, $neo4p_query);
  335.  
  336.     try {
  337.         $nhs_trust =            $values[$header_map{"RP07"}];
  338.         $nhs_trust_location =   $values[$header_map{"IN03_lvl1"}];
  339.         $degree_of_harm =       $values[$header_map{"PD09"}];
  340.         $patient_age =          $values[$header_map{"Age_at_Incident"}];
  341.         $patient_sex =          $values[$header_map{"PD02"}];
  342.         $patient_ethnicity =    $values[$header_map{"PD11"}];
  343.         $incident_id =          $values[$header_map{"incidentID"}];
  344.         $incident_date =        $values[$header_map{"IN01"}];
  345.         $incident_hour =        $values[$header_map{"IN02_A_01"}];
  346.         $incident_description = $values[$header_map{"IN07"}];
  347.         $incident_category =    $values[$header_map{"IN05_lvl1"}];
  348.         $incident_reporter =    $values[$header_map{"ST01_LVL1"}];
  349.         $incident_speciality =  $values[$header_map{"PD05_lvl1"}];
  350.  
  351.         # Normalize double quotes in incident description
  352.         $incident_description =~ s/"/\\"/g;
  353.  
  354.         # Assign unique trust id just to ensure uniqueness on set
  355.         my $trust_incident_id = $incident_id . "_" . $nhs_trust;
  356.  
  357.         # Normalize incident hour
  358.         if ($incident_hour eq 'NOT_DEFINED') {
  359.             $incident_hour = '00';
  360.         } else {
  361.             $incident_hour = substr($incident_hour, 0, 2);
  362.         }
  363.  
  364.         # Normalize date
  365.         my $incident_timestamp = DateTime::Format::Excel
  366.             ->parse_datetime($incident_date)->ymd . "T" .
  367.             $incident_hour . ":00:00";
  368.  
  369.         # Build nodes
  370.  
  371.         # Create nodes
  372.        
  373.         # Create unique NHS Trust node
  374.         if (!defined($created_nhs_trust_node)) {
  375.                      
  376.             $created_nhs_trust_node = 1;
  377.            
  378.             ($neo4p_query, $last_known_query) =
  379.                 ($create_nhs_trust_query, $create_nhs_trust_cql);
  380.  
  381.             &run_query(
  382.                 $last_known_query,
  383.                 $neo4p_query,
  384.                 { "code" => "RP07", "name" => $nhs_trust });
  385.         }
  386.  
  387.         if (!defined($created_nhs_trust_location{$nhs_trust_location})) {
  388.             # Create unique NHS Trust Location node
  389.             ($neo4p_query, $last_known_query) =
  390.                 ($create_nhs_trust_location_query
  391.                 , $create_nhs_trust_location_cql);
  392.                
  393.             &run_query(
  394.                 $last_known_query,
  395.                 $neo4p_query,
  396.                 { "location_level_01" => $nhs_trust_location });
  397.            
  398.             # Create relationship between NHS Trust/Location
  399.             ($neo4p_query, $last_known_query) =
  400.                 ($create_nhs_trust_location_rel_query
  401.                 , $create_nhs_trust_location_rel_cql);
  402.                
  403.             &run_query(
  404.                 $last_known_query,
  405.                 $neo4p_query,
  406.                 {"name" => $nhs_trust, "location_level_01" => $nhs_trust_location });
  407.            
  408.             $created_nhs_trust_location{$nhs_trust_location} = 1;
  409.         }
  410.        
  411.         # Create unique Incident node
  412.         ($neo4p_query, $last_known_query) =
  413.             ($create_incident_query, $create_incident_cql);
  414.            
  415.         &run_query(
  416.             $last_known_query,
  417.             $neo4p_query,
  418.             { "incident_id" => $incident_id
  419.             , "incident_timestamp" => $incident_timestamp
  420.             , "incident_description" => $incident_description });
  421.            
  422.         # Create unique Incident node NRLS_DATA_TYPE relationship ('INO7')
  423.         ($neo4p_query, $last_known_query) =
  424.             ($create_incident_ndt_rel_query, $create_incident_ndt_rel_cql);
  425.            
  426.         &run_query(
  427.             $last_known_query,
  428.             $neo4p_query,
  429.             { "incident_id" => $incident_id, "code" => "IN07" });
  430.        
  431.         # Create relationship to NHS Trust ${nhs_trust} ${incident_id}
  432.         ($neo4p_query, $last_known_query) =
  433.             ($create_incident_nhs_trust_rel_query
  434.             , $create_incident_nhs_trust_rel_cql);
  435.            
  436.         &run_query(
  437.             $last_known_query,
  438.             $neo4p_query,
  439.             { "name" => $nhs_trust, "incident_id" => $incident_id });
  440.                    
  441.         # Create relationship to NHS Trust Location
  442.         ($neo4p_query, $last_known_query) =
  443.             ($create_incident_ntl_rel_query, $create_incident_ntl_rel_cql);
  444.            
  445.         &run_query(
  446.             $last_known_query,
  447.             $neo4p_query,
  448.             { "location_level_01" => $nhs_trust_location
  449.             , "incident_id" => $incident_id });
  450.        
  451.         # Create unique Incident Category node
  452.         ($neo4p_query, $last_known_query) =
  453.             ($create_incident_category_query, $create_incident_category_cql);
  454.            
  455.         &run_query(
  456.             $last_known_query,
  457.             $neo4p_query,
  458.             { "code" => "IN05_lvl1"
  459.             , "category_level_01" => $incident_category });
  460.        
  461.         # Create unique Incident Category relationship
  462.         ($neo4p_query, $last_known_query) =
  463.             ($create_incident_category_rel_query
  464.             , $create_incident_category_rel_cql);
  465.            
  466.         &run_query(
  467.             $last_known_query,
  468.             $neo4p_query,
  469.             { "incident_id" => $incident_id
  470.             , "category_level_01" => $incident_category });
  471.        
  472.         # Create unique Incident Speciality node
  473.         ($neo4p_query, $last_known_query) =
  474.             ($create_incident_speciality_query, $create_incident_speciality_cql);
  475.            
  476.         &run_query(
  477.             $last_known_query,
  478.             $neo4p_query,
  479.             { "code" => "PD05_lvl1"
  480.             , "speciality_level_01" => $incident_speciality });
  481.        
  482.         # Create unique Incident Speciality relationship
  483.         ($neo4p_query, $last_known_query) =
  484.             ($create_incident_speciality_rel_query
  485.             , $create_incident_speciality_rel_cql);
  486.            
  487.         &run_query(
  488.             $last_known_query,
  489.             $neo4p_query,
  490.             { "incident_id" => $incident_id
  491.             , "speciality_level_01" => $incident_speciality });
  492.        
  493.         # Create unique Incident Reporter node
  494.         ($neo4p_query, $last_known_query) =
  495.             ($create_incident_reporter_query, $create_incident_reporter_cql);
  496.            
  497.         &run_query(
  498.             $last_known_query,
  499.             $neo4p_query,
  500.             { "code" => "ST01_LVL1"
  501.             , "reporter_level_01" => $incident_reporter });
  502.        
  503.         # Create unique Incident Reporter relationship
  504.         ($neo4p_query, $last_known_query) =
  505.             ($create_incident_reporter_rel_query
  506.             , $create_incident_reporter_rel_cql);
  507.            
  508.         &run_query(
  509.             $last_known_query,
  510.             $neo4p_query,
  511.             { "incident_id" => $incident_id
  512.             , "reporter_level_01" => $incident_reporter });
  513.        
  514.         # Create unique Patient node
  515.         ($neo4p_query, $last_known_query) =
  516.             ($create_incident_patient_query
  517.             , $create_incident_patient_cql);
  518.            
  519.         &run_query(
  520.             $last_known_query,
  521.             $neo4p_query,
  522.             { "code" => "Age_at_Incident"
  523.             , "patient_age" => $patient_age
  524.             , "patient_sex" => $patient_sex
  525.             , "patient_ethnicity" => $patient_ethnicity});
  526.        
  527.         # Create unique Incident Patient relationship
  528.         ($neo4p_query, $last_known_query) =
  529.             ($create_incident_patient_rel_query
  530.             , $create_incident_patient_rel_cql);
  531.            
  532.         &run_query(
  533.             $last_known_query,
  534.             $neo4p_query,
  535.             { "incident_id" => $incident_id
  536.             , "patient_age" => $patient_age
  537.             , "patient_sex" => $patient_sex
  538.             , "patient_ethnicity" => $patient_ethnicity });
  539.        
  540.         # Create unique Degree Of Harm node
  541.         ($neo4p_query, $last_known_query) =
  542.             ($create_incident_doh_query
  543.             , $create_incident_doh_cql);
  544.            
  545.         &run_query(
  546.             $last_known_query,
  547.             $neo4p_query,
  548.             { "code" => "PD09"
  549.             , "degree_of_harm" => $degree_of_harm });
  550.        
  551.         # Create unique Degree Of Harm relationship
  552.         ($neo4p_query, $last_known_query) =
  553.             ($create_incident_doh_rel_query
  554.             , $create_incident_doh_rel_cql);
  555.            
  556.         &run_query(
  557.             $last_known_query,
  558.             $neo4p_query,
  559.             { "incident_id" => $incident_id
  560.             , "degree_of_harm" => $degree_of_harm});
  561.        
  562.     } catch {
  563.         my $current_row_number = $row->row_number() + 1;
  564.         say STDERR "Failure at row number $current_row_number in $input_file : $_.";
  565.         say STDERR "Last known query $last_known_query."
  566.             if (defined($last_known_query));
  567.            
  568.         if (defined($neo4p_query) and defined($neo4p_query->errstr)) {
  569.             say STDERR "Last known neo4p query error: " , $neo4p_query->errstr;
  570.         }
  571.  
  572.         foreach my $required_column (@required_columns) {
  573.             if (defined($header_map{$required_column}) and
  574.                 defined($values[$header_map{$required_column}])) {
  575.                 say STDERR "Column $required_column : " , $values[$header_map{$required_column}];
  576.             }
  577.         }
  578.     };
  579.  
  580.     unless ($row->row_number() % 500) {
  581.         say "Processed " , $row->row_number() , " rows. " , scalar localtime;
  582.     }
  583. }
  584.  
  585. sub run_query {
  586.     my ($cql, $query, $params) = @_;
  587.    
  588.     $query->execute($params)
  589.         or die("Could not execute query $cql");
  590. }
Advertisement
Add Comment
Please, Sign In to add comment