Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>using System; using System.Data; using System.Data.SQLite; using System.IO; namespace CSVImport { internal class Program { private static void Main(string[] args) { using (SQLiteConnection con = new SQLiteConnection("data source=data.db3")) { if (!File.Exists("data.db3")) { con.Open(); using (SQLiteCommand cmd = con.CreateCommand()) { cmd.CommandText = @" CREATE TABLE [Import] ( [RowId] integer PRIMARY KEY AUTOINCREMENT NOT NULL, [FeatType] varchar, [FeatName] varchar, [Value] varchar, [Actual] decimal, [Nominal] decimal, [Dev] decimal, [TolMin] decimal, [TolPlus] decimal, [OutOfTol] decimal, [Comment] nvarchar);"; cmd.ExecuteNonQuery(); } con.Close(); } con.Open(); using (SQLiteCommand insertCommand = con.CreateCommand()) { insertCommand.CommandText = @" INSERT INTO Import (FeatType, FeatName, Value, Actual, Nominal, Dev, TolMin, TolPlus, OutOfTol, Comment) VALUES (@FeatType, @FeatName, @Value, @Actual, @Nominal, @Dev, @TolMin, @TolPlus, @OutOfTol, @Comment);"; insertCommand.Parameters.Add(new SQLiteParameter("@FeatType", DbType.String)); insertCommand.Parameters.Add(new SQLiteParameter("@FeatName", DbType.String)); insertCommand.Parameters.Add(new SQLiteParameter("@Value", DbType.String)); insertCommand.Parameters.Add(new SQLiteParameter("@Actual", DbType.Decimal)); insertCommand.Parameters.Add(new SQLiteParameter("@Nominal", DbType.Decimal)); insertCommand.Parameters.Add(new SQLiteParameter("@Dev", DbType.Decimal)); insertCommand.Parameters.Add(new SQLiteParameter("@TolMin", DbType.Decimal)); insertCommand.Parameters.Add(new SQLiteParameter("@TolPlus", DbType.Decimal)); insertCommand.Parameters.Add(new SQLiteParameter("@OutOfTol", DbType.Decimal)); insertCommand.Parameters.Add(new SQLiteParameter("@Comment", DbType.String)); string[] files = Directory.GetFiles(Environment.CurrentDirectory, "TextFile*.*"); foreach (string file in files) { string[] lines = File.ReadAllLines(file); bool parse = false; foreach (string tmpLine in lines) { string line = tmpLine.Trim(); if (!parse &amp;&amp; line.StartsWith("Feat. Type,")) { parse = true; continue; } if (!parse || string.IsNullOrEmpty(line)) { continue; } foreach (SQLiteParameter parameter in insertCommand.Parameters) { parameter.Value = null; } string[] values = line.Split(new[] {','}); for (int i = 0; i &lt; values.Length - 1; i++) { SQLiteParameter param = insertCommand.Parameters[i]; if (param.DbType == DbType.Decimal) { decimal value; param.Value = decimal.TryParse(values[i], out value) ? value : 0; } else { param.Value = values[i]; } } insertCommand.ExecuteNonQuery(); } } } con.Close(); } } } } </code></pre> <p>results:</p> <pre> 1 Point _FF_PLN_A_1 X -17.445 -17.445 0 -999 999 0 NULL 2 Point _FF_PLN_A_1 Y -195.502 -195.502 0 -999 999 0 NULL 3 Point _FF_PLN_A_1 Z 32.867 33.5 -0.633 -0.8 0.8 0 NULL 4 Point _FF_PLN_A_2 X -73.908 -73.908 0 -999 999 0 NULL 5 Point _FF_PLN_A_2 Y -157.957 -157.957 0 -999 999 0 NULL 6 Point _FF_PLN_A_2 Z 32.792 33.5 -0.708 -0.8 0.8 0 NULL 7 Point _FF_PLN_A_3 X -100.18 -100.18 0 -999 999 0 NULL 8 Point _FF_PLN_A_3 Y -142.797 -142.797 0 -999 999 0 NULL 9 Point _FF_PLN_A_3 Z 32.768 33.5 -0.732 -0.8 0.8 0 NULL 10 Point _FF_PLN_A_4 X -160.945 -160.945 0 -999 999 0 NULL 11 Point _FF_PLN_A_4 Y -112.705 -112.705 0 -999 999 0 NULL 12 Point _FF_PLN_A_4 Z 32.719 33.5 -0.781 -0.8 0.8 0 NULL 13 Point _FF_PLN_A_5 X -158.096 -158.096 0 -999 999 0 NULL 14 Point _FF_PLN_A_5 Y -73.821 -73.821 0 -999 999 0 NULL 15 Point _FF_PLN_A_5 Z 32.756 33.5 -0.744 -0.8 0.8 0 NULL 16 Point _FF_PLN_A_6 X -195.67 -195.67 0 -999 999 0 NULL 17 Point _FF_PLN_A_6 Y -17.375 -17.375 0 -999 999 0 NULL 18 Point _FF_PLN_A_6 Z 32.767 33.5 -0.733 -0.8 0.8 0 NULL 19 Point _FF_PLN_A_7 X -173.759 -173.759 0 -999 999 0 NULL 20 Point _FF_PLN_A_1 X -17.445 -17.445 0 -999 999 0 NULL 21 Point _FF_PLN_A_1 Y -195.502 -195.502 0 -999 999 0 NULL 22 Point _FF_PLN_A_1 Z 32.867 33.5 -0.633 -0.8 0.8 0 NULL 23 Point _FF_PLN_A_2 X -73.908 -73.908 0 -999 999 0 NULL 24 Point _FF_PLN_A_2 Y -157.957 -157.957 0 -999 999 0 NULL 25 Point _FF_PLN_A_2 Z 32.792 33.5 -0.708 -0.8 0.8 0 NULL 26 Point _FF_PLN_A_3 X -100.18 -100.18 0 -999 999 0 NULL 27 Point _FF_PLN_A_3 Y -142.797 -142.797 0 -999 999 0 NULL 28 Point _FF_PLN_A_3 Z 32.768 33.5 -0.732 -0.8 0.8 0 NULL 29 Point _FF_PLN_A_4 X -160.945 -160.945 0 -999 999 0 NULL 30 Point _FF_PLN_A_4 Y -112.705 -112.705 0 -999 999 0 NULL 31 Point _FF_PLN_A_4 Z 32.719 33.5 -0.781 -0.8 0.8 0 NULL 32 Point _FF_PLN_A_5 X -158.096 -158.096 0 -999 999 0 NULL 33 Point _FF_PLN_A_5 Y -73.821 -73.821 0 -999 999 0 NULL 34 Point _FF_PLN_A_5 Z 32.756 33.5 -0.744 -0.8 0.8 0 NULL 35 Point _FF_PLN_A_6 X -195.67 -195.67 0 -999 999 0 NULL 36 Point _FF_PLN_A_6 Y -17.375 -17.375 0 -999 999 0 NULL 37 Point _FF_PLN_A_6 Z 32.767 33.5 -0.733 -0.8 0.8 0 NULL 38 Point _FF_PLN_A_7 X -173.759 -173.759 0 -999 999 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL</pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload