Commit 2cfbb516 authored by Alan Ing's avatar Alan Ing
Browse files

initial

parents

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30723.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "load_db_personable", "load_db_personable\load_db_personable.csproj", "{45E01693-F676-4D7C-AFD1-E473585A76CB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{45E01693-F676-4D7C-AFD1-E473585A76CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45E01693-F676-4D7C-AFD1-E473585A76CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45E01693-F676-4D7C-AFD1-E473585A76CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45E01693-F676-4D7C-AFD1-E473585A76CB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
\ No newline at end of file
using CsvHelper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
namespace load_db_personable
{
class Program
{
private const string ConnectionString = "Data Source=0.0.0.0;Initial Catalog=redJOHN;Persist Security Info=True;User ID=XXX;Password=YYY";
private const string PathPersonable = @"ocean.1to3grams.gender_age.rmatrix.csv";
private const string FileHeaders =
@"word,ext,agr,con,neu,ope";
private const string TableName = "PERSONABLE";
static void Main()
{
Console.WriteLine(("Start"));
// (re) create database table
// word is varchar, all the other values are real
var myConnection = new SqlConnection(ConnectionString);
SqlCommand myCommand = null;
try
{
myConnection.Open();
myCommand = new SqlCommand(@"if OBJECT_ID('" + TableName + "') is not null DROP TABLE " + TableName, myConnection);
myCommand.ExecuteNonQuery();
String createTable = @"CREATE TABLE [dbo].[" + TableName + @"]([word] [varchar](40) NOT NULL";
for (int i = 1; i < FileHeaders.Split(',').Length; i++)
{
createTable += ",[" + FileHeaders.Split(',')[i] + "] [real] NULL";
}
createTable += ")";
myCommand = new SqlCommand(createTable, myConnection);
myCommand.ExecuteNonQuery();
}
catch (Exception e)
{
if (myCommand != null) Console.WriteLine(myCommand.CommandText);
Console.WriteLine(e.ToString());
Console.Read();
}
// open and iterate through file
var file = new CsvReader(File.OpenText(PathPersonable));
while (file.Read())
{
String DEBUG = "";
var nameValue = new Dictionary<string, string>(); //column name / value
string[] fileHeaderArray = FileHeaders.Split(',');
for (int j = 0; j < fileHeaderArray.Length; j++)
{
// read file values into dictionary with col name
nameValue.Add(fileHeaderArray[j],
j == 0 ? file.GetField<string>(0) : file.GetField<string>(fileHeaderArray[j]));
}
try
{
myCommand =
new SqlCommand(
"INSERT INTO " + TableName + "(" + FileHeaders + ") VALUES (@" +
FileHeaders.Replace(",", ",@") + ")", myConnection);
foreach (var pair in nameValue)
{
String name = pair.Key;
String value = pair.Value;
SqlDbType type = name.Equals("word") ? SqlDbType.VarChar : SqlDbType.Real;
var p = new SqlParameter("@" + name, type) { Value = value };
myCommand.Parameters.Add(p);
DEBUG += value + " ";
}
myCommand.ExecuteNonQuery();
}
catch (Exception e)
{
if (myCommand != null) Console.WriteLine(myCommand.CommandText);
Console.WriteLine(e.ToString());
Console.WriteLine(DEBUG);
Console.Read();
}
}
try
{
myConnection.Close();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
Console.Read();
}
Console.WriteLine(("End"));
Console.Read();
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("load_db_personable")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("load_db_personable")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("bb75640f-6be4-4d25-8623-d3829b41cb07")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{45E01693-F676-4D7C-AFD1-E473585A76CB}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>load_db_personable</RootNamespace>
<AssemblyName>load_db_personable</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CsvHelper">
<HintPath>..\packages\CsvHelper.2.8.2\lib\net40-client\CsvHelper.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
c:\users\alaning\documents\visual studio 2013\Projects\load_db_personable\load_db_personable\bin\Debug\load_db_personable.exe.config
C:\Users\alaning\Documents\Visual Studio 2013\Projects\load_db_personable\load_db_personable\bin\Debug\load_db_personable.exe
C:\Users\alaning\Documents\Visual Studio 2013\Projects\load_db_personable\load_db_personable\bin\Debug\load_db_personable.pdb
C:\Users\alaning\Documents\Visual Studio 2013\Projects\load_db_personable\load_db_personable\bin\Debug\CsvHelper.dll
C:\Users\alaning\Documents\Visual Studio 2013\Projects\load_db_personable\load_db_personable\bin\Debug\CsvHelper.pdb
C:\Users\alaning\Documents\Visual Studio 2013\Projects\load_db_personable\load_db_personable\bin\Debug\CsvHelper.xml
C:\Users\alaning\Documents\Visual Studio 2013\Projects\load_db_personable\load_db_personable\obj\Debug\load_db_personable.csprojResolveAssemblyReference.cache
C:\Users\alaning\Documents\Visual Studio 2013\Projects\load_db_personable\load_db_personable\obj\Debug\load_db_personable.exe
C:\Users\alaning\Documents\Visual Studio 2013\Projects\load_db_personable\load_db_personable\obj\Debug\load_db_personable.pdb
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment