title: Importing and Modifying Data in MySQL Workbench 6.0
body: <p>I am new to MySQL and have not been coding for quite a few years. I am building a database in MySQL Workbench 6.0 and need to import multiple NEM12 text files from data logs. The text files have a Record Indicator (RI) as the first 3 characters (eg 200, 300, 900). </p>
  
  <p>I need to get the second entry from the 200 RI lines (NMI)and add it to the following 300 lines as there is no reference to the NMI but this is the info I am interested. Note there is normally one 200 line for several hundred 300 lines. To further complicate this there will be another 200 line with a different NMI and 300 lines following that are for the new NMI.</p>
  
  <p><strong>NMI Data Record 200</strong> </p>
  
  <pre>
  RecordIndicator,NMI,NMIConfiguration,RegisterID,NMISuffix,MDMDataStreamIdentifier,
  MeterSerialNumber,UOM,IntervalLength,NextScheduledReadDate
  </pre>
  
  <p><strong>Example</strong> </p>
  
  <pre>
  200,VABD000163,E1Q1,1,E1,N1,METSER123,kWh,30,20040120 
  </pre>
  
  <p><strong>NMI Data Record 300</strong> </p>
  
  <pre>
  RecordIndicator,IntervalDate,IntervalValue1 . . . IntervalValueN,
  QualityMethod,ReasonCode,ReasonDescription,UpdateDateTime,MSATSLoadDateTime 
  </pre>
  
  <p><strong>Example</strong> </p>
  
  <pre>
  300,20030501,50.1, . . . ,21.5,V,,,20030101153445,20030102023012
  </pre>
  
  <p>Some lines below are from the logfile - note that it doesn't have a line gap in the file between the lines</p>
  
  <pre>
  100,NEM12,201307101326,WBAYM,QEEE000514,
  
  200,QEEE000514,E1Q1,,E1,N1,90401242,kWh,30,
  
  300,20120701,67.46,80.42,85.38,85.22,82.3,79.23,71.23,81.41,93.82,100.93,125.89,113.79,102.37,117.25,125.7,140.16,134.14,127.62,123.3,144.13,144.48,157.73,141.28,143.74,135.71,148.48,151.81,160.32,148.67,145.41,135.62,148.35,128.7,142.37,136.1,141.31,98.21,102.14,80.86,82.69,74.3,75.84,69.15,75.01,67.78,72.96,66.75,71.1,A,,,20120702013914,
  
  300,20120702,61.63,74.69,80.45,78.46,77.31,74.91,65.57,77.63,97.82,126.78,119.84,131.58,130.08,138.75,111.74,118.94,121.66,128.45,121.47,142.46,139.1,153.82,121.09,128.77,145.6,159.1,147.07,133.82,126.69,135.9,141.28,151.01,127.23,120.19,117.44,133.18,110.43,121.57,116.9,119.17,112.03,107.49,94.05,92.9,81.63,85.76,81.09,85.47,A,,,20120703013936,
  
  300,20120703,71.46,71.33,78.94,76.83,77.57,72.86,65.92,78.85,97.73,124.77,118.69,130.14,127.46,136.35,107.74,116.13,115.46,127.55,120.74,133.79,138.98,147.84,123.17,123.33,117.98,133.66,122.69,137.28,129.73,120.45,139.81,150.37,128.32,120.74,112.67,115.46,114.24,127.42,113.25,122.43,108.8,107.71,92.8,90.46,79.84,83.74,81.12,83.2,A,,,20120704013954,
  300,20120704,73.95,82.62,88.19,87.81,87.78,83.04,75.26,85.34,94.98,119.07,113.86,122.24,123.84,131.3,107.9,112.48,120.13,117.7,115.42,119.42,125.47,137.6,130.11,113.95,119.1,144.8,135.87,123.2,109.25,116.77,113.76,133.95,126.24,119.3,105.86,107.39,107.52,111.81,109.22,111.36,100.19,98.88,86.27,80.8,72.16,75.33,70.56,74.02,A,,,20120705013928,
  
  300,20120705,60.7,61.47,70.43,66.56,67.14,63.9,56,67.26,88.8,113.66,106.75,118.78,118.08,124.8,101.15,105.82,112.86,118.27,121.22,135.3,130.08,122.27,111.62,120.26,105.12,132.13,139.52,134.5,116.32,124.03,125.31,137.98,111.52,111.97,104.38,117.25,106.78,122.62,106.46,106.82,100.38,102.72,86.46,77.31,71.01,72.26,69.28,71.71,A,,,20120706013931,
  300,20120706,57.22,58.66,66.5,63.39,66.43,64.64,55.01,64.83,89.15,103.84,101.86,105.18,108.22,125.06,114.21,103.65,115.87,120.32,119.33,133.76,134.4,142.05,119.23,126.94,122.78,148.06,141.86,124.16,114.27,116,109.6,134.82,127.52,127.71,111.36,119.9,114.62,125.09,109.89,122.08,113.02,106.3,87.26,80.38,72.29,78.34,73.98,77.09,A,,,20120707013935,
  
  300,20120707,64.61,66.21,72.22,70.85,75.14,72.93,62.75,71.46,79.81,96.54,108.38,100.93,112.45,125.18,117.44,103.36,113.86,128.35,122.59,130.08,122.82,119.52,123.74,141.7,132.67,133.66,116.61,130.85,125.31,133.44,112.42,124.03,115.81,120.9,89.22,89.79,77.06,90.59,81.98,86.88,80.99,82.98,76,76.7,62.37,66.82,63.1,65.98,A,,,20120708013912,
  300,20120708,57.15,69.15,73.18,75.1,73.22,70.43,63.68,72.9,84.83,104.99,107.36,103.17,95.04,110.02,113.66,129.63,128.9,121.76,119.04,134.14,120.86,125.57,136.16,142.5,135.01,122.98,122.21,126.69,132.64,137.12,122.69,124.77,123.23,126.66,109.25,116.9,88.42,93.06,68.83,73.15,66.18,66.66,61.34,67.78,61.31,64.13,59.9,63.97,A,,,20120709013915,
  300,20120709,52.96,65.57,72.48,70.46,69.95,68.16,59.68,72.99,90.91,122.43,115.04,124.58,124.51,134.27,113.12,112.03,117.41,120.26,123.04,144.51,139.52,151.52,115.74,127.46,125.44,133.92,127.04,135.01,134.98,136.67,109.28,132.1,129.73,136.48,120.35,120.93,112.19,128.19,115.71,124.77,117.15,111.71,97.44,91.46,81.92,82.69,80.51,82.91,A,,,20120710013929,
  300,20120710,72.93,85.02,91.07,90.98,89.18,86.56,74.18,88.1,102.18,122.34,115.9,122.82,128.06,139.58,116.7,116.99,120.03,124.26,117.47,144.26,143.17,141.22,123.81,124.32,115.97,148.45,144.7,147.94,124.38,126.66,118.53,142.98,136.13,134.59,118.27,121.95,116,128.16,116.38,118.46,110.02,108.86,96.22,92.64,80.38,86.94,80.1,83.84,A,,,20120711013916,
  300,20120711,64.16,70.94,77.22,75.94,76.8,71.39,62.82,76.22,98.24,119.87,117.09,127.33,123.3,135.07,105.76,115.94,117.66,124.74,124.1,141.09,136.93,141.98,119.17,126.78,119.04,135.78,140.7,144.19,127.07,120.61,117.6,129.89,133.22,140.48,122.62,128.67,114.08,121.82,115.87,125.86,111.2,108.58,94.37,91.97,80.58,84.06,80.38,80.86,A,,,20120712013916,
  300,20120712,67.3,70.75,77.31,75.55,75.1,72.06,63.78,77.73,93.38,113.44,119.94,119.87,125.57,137.12,113.89,116.1,118.46,123.17,127.49,142.18,145.38,150.98,135.26,134.62,136.42,164.74,155.78,142.4,135.04,140.51,126.21,145.09,138.3,137.18,126.69,126.37,125.47,129.86,120.32,117.76,110.69,112.26,98.18,92.38,81.54,86.98,81.73,86.27,A,,,20120713013923,
  300,20120713,65.02,73.06,77.02,75.71,75.39,72.38,64.86,75.49,97.82,113.6,117.18,116.38,117.25,137.31,127.78,121.15,127.39,123.55,118.27,134.66,143.65,145.34,128.9,140.32,142.5,147.65,134.05,155.01,129.82,123.33,114.88,126.59,118.02,122.66,115.62,116.51,105.79,118.14,107.9,113.86,104.38,108.1,93.41,92.96,72.96,75.3,69.76,72.86,A,,,20120714014000,
  300,20120714,63.74,78.56,81.82,82.98,80.54,79.78,69.73,82.4,103.17,123.84,118.78,128.1,131.1,144.99,117.31,127.01,123.49,136.74,126.62,150.98,148.03,153.73,132.38,139.23,153.92,162.08,172.83,142.98,142.3,145.34,149.25,134.24,125.12,126.27,98.21,99.07,87.42,100.06,90.27,95.94,80.51,78.34,70.11,78.3,69.25,72.54,68.67,72.96,A,,,20120715014259,
  300,20120715,63.52,77.18,82.46,81.95,80.61,77.63,69.66,83.42,96.32,104.58,110.18,122.08,106.5,134.53,135.55,133.44,107.65,124.35,124.35,130.75,136.67,147.01,142.72,126.37,124.74,154.5,139.55,128.54,121.31,129.38,118.37,128.51,114.69,118.5,118.91,112.42,82.98,89.98,76.32,76.35,71.58,74.21,66.88,73.79,66.66,68.77,68,69.7,A,,,20120716013951,
  300,20120716,63.9,86.4,90.24,91.01,90.11,85.31,78.43,87.9,102.08,127.26,125.18,131.36,132.13,134.14,110.34,121.7,123.2,122.72,118.08,135.26,133.09,139.62,116.32,131.55,121.22,146.91,140.32,127.78,120.42,139.94,133.47,137.15,120,124.35,115.55,118.59,114.72,124.86,119.14,122.72,109.63,107.55,92.83,88.99,78.11,79.58,74.18,78.88,A,,,20120717013928,
  300,20120717,63.62,66.21,73.02,70.11,70.88,66.98,59.2,72.06,96.8,136.67,128.48,129.7,131.36,139.97,112.26,123.04,130.5,135.42,142.85,163.33,147.07,140.45,131.23,149.31,144.32,164.16,159.36,141.18,136.03,142.18,149.66,166.11,142.37,133.95,131.78,133.22,125.15,130.3,127.74,128.38,125.28,120.96,98.11,93.31,87.33,91.55,80.9,94.14,A,,,20120718013923,
  </pre>