 |
|
 |
Check if your csv file is in unicode.
|
|
|
|
 |
|
|
 |
|
 |
I am trying to download, but the downloaded zip file has no files. :(
|
|
|
|
 |
|
 |
Worked for me. Try again.
|
|
|
|
 |
|
 |
it appears as if this could be made to perform conditional uploads in the section:
System.Data.Odbc.OdbcConnection(DSN="MyDSN");
//Open the connection
conn.Open();
//Fetch records from CSV
sql_select ="select * from ["+ filetable +"]";
I have tried several where clauses with it yet it fails everytime could someone please post an example in this format that would work? I am appraently missing something syntactically.
|
|
|
|
 |
|
 |
I tried translating the code but received a ton of error messages.
I am pretty new to VB so I am clueless as to what is wrong here.
Thanks a lot!
Tammy
|
|
|
|
 |
|
 |
If you use this example, the Text Driver and JET database drivers are limited to only 255 character columns. here is come code that will work for any size. It will import a TAB delimited file:
Public Function ImportTabCSV(ByVal filename As String, Optional ByVal HasHeaderLine As Boolean = False) As DataTable
Dim sr As New StreamReader(filename)
Dim line As String = ""
Dim firstLine As String = String.Empty
Dim intLineIdentifier As Integer = 0
Dim dtCIMExtract As DataTable = Nothing
Dim delimiter As Char = Chr(9)
While Not line Is Nothing
line = sr.ReadLine()
If intLineIdentifier = 0 And HasHeaderLine Then
firstLine = line
dtCIMExtract = GenerateColumnsForDataTable(firstLine, delimiter)
intLineIdentifier = intLineIdentifier + 1
Else
Dim strColumndata As String() = line.Split(delimiter)
If dtCIMExtract Is Nothing Then
dtCIMExtract = GenerateColumnsForDataTable(strColumndata.Length)
End If
Dim drRow As DataRow = dtCIMExtract.LoadDataRow(strColumndata, LoadOption.OverwriteChanges)
End If
If sr.EndOfStream Then Exit While
End While
sr.Close()
Return dtCIMExtract
End Function
Private Function GenerateColumnsForDataTable(ByVal colCount As Integer) As DataTable
Dim dt As New DataTable("CSVTable")
For i As Integer = 1 To colCount
dt.Columns.Add("Column" & i, GetType(String), Nothing)
Next
Return dt
End Function
Private Function GenerateColumnsForDataTable(ByVal strColumns As String, ByVal separator As Char) As DataTable
Dim dtCodeDesc As New DataTable("CSVTable")
Dim strColumnArray As String() = strColumns.Split(separator)
For Each strcol As String In strColumnArray
dtCodeDesc.Columns.Add(New DataColumn(strcol, GetType(String)))
Next
Return dtCodeDesc
End Function
If you need comma delimited, you just need to change the separator and the line to parse.
Derek Wade
|
|
|
|
 |
|
|
 |
|
 |
Make sure that ~all~ decimal values contain a decimal "."
If the first few lines of data do not have a decimal "." in the decimal column, the ODBC driver defaults the whole column to ~int~.
modified on Wednesday, April 30, 2008 8:48 PM
|
|
|
|
 |
|
 |
Mukund,
I have found your project very helpful in importing CSV data on a major conversion at work.
I have one problem though. Decimal data is not coming across with anything after the dot "."
For Example, here are two lines that I am importing:
101,SOME TEXT,03/02/2008,28,43301,Sales: Dept. MEMBERSHIP,0,9.95
100,SOME TEXT,03/02/2008,28,43301,Sales: Dept. MEMBERSHIP,0,1.67
The decimal values are at the end of the data lines (9.95 and 1.67). When importing, I get 9.00 and 1.00.
I have tried saving the file as .txt and I have looked at Regional Setting in case there was a problem there. But no, neither change made a difference. I still get 9.00 and 1.00 in those data lines.
Any help would be great!
~P
|
|
|
|
 |
|
 |
what licenses are included with this project?
|
|
|
|
 |
|
 |
I would like the first column to be a string and the rest to be floats, but it only displays them as integers
Can anyone point me in the right direction.
Thanks
|
|
|
|
 |
|
 |
I have a 280 rows CSV file, i downloaded the demo program and i execuded it (FinalCSVReader.exe) and it worked just fine. I have strings, integers, doubles, two decimal places when needed, nulls... they look just fine.
Good luck!
Thanks alot for this Mukund!!
|
|
|
|
 |
|
 |
While Inserting the data rows and columns cannot be with in the loop. Row should be outside column loop.
|
|
|
|
 |
|
 |
how to format colum before i run a query..
i have a colum which have value 00100900120070209105914020391232, but after i run query, the colum became 1.00900120070209105914020391232E+32.
i want to display it original value...
how to do it...
i have wrote a .ini file :
s2 = "ColNameHeader=True"
s3 = "Format=" & strFormat
s4 = "MaxScanRows=0"
s5 = "CharacterSet=OEM"
's5 = "CharacterSet=ANSI"
s6 = "Col1=Field1 Char Width 20"
s7 = "Col2=Field2 Char Width 4"
s8 = "Col3=Field3 Char Width 32"
Please Help me
|
|
|
|
 |
|
 |
I need to make the srno number a unique id. When I import I want this the to increment up.
Any help would be greatly appreciated
|
|
|
|
 |
|
 |
I have a CSV file that is formatted like this;
08/09/2007 00:00:06,022.514.054,Ardmore South,OK,1,6040,External 0 Alarm On
Note that the first Comma Delimiter is between the 06 and 022. The import routine is setting the space between the 2007 and the 00: as a delimited field. I only want the Comma as the delimiter. Any idea why it is doing this?
|
|
|
|
 |
|
 |
I tried implementing this, reading and csv-file, but I get some odd behaviour, it only
works on 2003 Server, on windows xp I only get the first column !?! ..my head is empty
can somebody help ..please
pierre
|
|
|
|
 |
|
 |
Please help me.
I use ODBC connection and Dataset among your soucecode.
But any string containing numeric is recognized decimal type.
example) SK30 -> 30.0000 (broken)
sk30 -> sk30 (normal)
Relation Source code.
------------------------------------------------------
# region Function For Importing Data From CSV File
public DataSet ConnectCSV(string filetable)
{
DataSet ds = new DataSet();
try
{
// You can get connected to driver either by using DSN or connection string
// Create a connection string as below, if you want to use DSN less connection. The DBQ attribute sets the path of directory which contains CSV files
string strConnString="Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq="+txtCSVFolderPath.Text.Trim()+";Extensions=asc,csv,tab,txt;Persist Security Info=False";
string sql_select;
System.Data.Odbc.OdbcConnection conn;
//Create connection to CSV file
conn = new System.Data.Odbc.OdbcConnection(strConnString.Trim());
// For creating a connection using DSN, use following line
//conn = new System.Data.Odbc.OdbcConnection(DSN="MyDSN");
//Open the connection
conn.Open();
//Fetch records from CSV
sql_select = "select * from ["+ filetable +"]";
obj_oledb_da = new System.Data.Odbc.OdbcDataAdapter(sql_select,conn);
//Fill dataset with the records from CSV file
obj_oledb_da.Fill(ds,"Stocks");
//Set the datagrid properties
dGridCSVdata.DataSource=ds;
dGridCSVdata.DataMember="Stocks";
//Close Connection to CSV file
conn.Close();
}
catch(Exception e) //Error
{
MessageBox.Show(e.Message);
}
return ds;
}
---------------------------------------------------------------------------------------------
text type :
2050762;1111111111115;abc;abcde@HANMAIL.NET;;;abc;469-884;abc;20051212;20070703;SK30;Flip Chip;Flip Chip Team;abd;;;;;Y;;;
2050762;1111111111115;abc;abcde@HANMAIL.NET;;;abc;469-884;abc;20051212;20070703;SK30;Flip Chip;Flip Chip Team;abd;;;;;Y;;;
In this sentence, sk30 --> 30.0000
How to solve it ?
GYseven
gy7choi@gmail.com
|
|
|
|
 |
|
 |
Hi,
Is there anyway for us to check whether the CSV file content is applying the scheme defined in schema.ini file or not?
|
|
|
|
 |
|
 |
hi,
I am developing a project where there is a need of importing a CSV file to database. As i have no idea about C# i am not able to understand ur C# code.
So can you plese tell me how to import the data using VB.NET.
Thank u...
Jats
|
|
|
|
 |
|
 |
If I am taking delimitor for the csv file as single quote (') then how hould I put it as delemitor in my connection string. When I am importing the file.
Thank you,
Regards,
Aleem.
S/W Engineer
Akebono Soft Technologies
aleem_abdul@akebonosoft.com.
|
|
|
|
 |
|
 |
Hello,
My problem is that i don't want to import the strings between some special characters, i want to import the whole text from a .txt or .doc file. How can i do that?
Thanks.
Sare
|
|
|
|
 |
|
 |
There are enough examples given in MSDN to do this. You may also get it on other sites. You need simple IO operation here. still I am giving you a sample code from MSDN:
The following code example shows a simple way to read text from a text file.
using System;
using System.IO;
class Test
{
public static void Main()
{
try
{
// Create an instance of StreamReader to read from a file.
// The using statement also closes the StreamReader.
using (StreamReader sr = new StreamReader("TestFile.txt"))
{
String line;
// Read and display lines from the file until the end of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
Console.WriteLine(line);
}
}
}
catch (Exception e)
{
// Let the user know what went wrong.
Console.WriteLine("The file could not be read:");
Console.WriteLine(e.Message);
}
}
}
|
|
|
|
 |
|
 |
I have a CSV file with 15 columns in it. I know the sample project was setup for just 2 columns. I am only getting 2 columns of data showing. If I edit the 14 in this line...for (int j = 1; j <= da.Tables["Stocks"].Columns.Count - 14; j++) to 13 I gain an additional column of data but the rows duplicate once. As I decrease the 14 one by one, each number I decrease by is how many duplicates of the rows I get. Can someone help me out on this?
// Now we will collect data from data table and insert it into database one by one
// Initially there will be no data in database so we will insert data in first two columns
// and after that we will update data in same row for remaining columns
// The logic is simple. 'i' represents rows while 'j' represents columns
cmd.Connection = con1;
cmd.CommandType = CommandType.Text;
cmd1.Connection = con1;
cmd1.CommandType = CommandType.Text;
con1.Open();
for (int i = 0; i <= da.Tables["Stocks"].Rows.Count - 1; i++)
{
for (int j = 1; j <= da.Tables["Stocks"].Columns.Count - 14; j++)
{
cmd.CommandText = "Insert into Test (srno, " + da.Tables["Stocks"].Columns[0].ColumnName.Trim() + ") values(" + (i + 1) + ",'" + da.Tables["Stocks"].Rows[i].ItemArray.GetValue(0) + "')";
// For UPDATE statement, in where clause you need some unique row
//identifier. We are using ‘srno’ in WHERE clause.
cmd1.CommandText = "Update Test set " + da.Tables["Stocks"].Columns[j].ColumnName.Trim() + " = '" + da.Tables["Stocks"].Rows[i].ItemArray.GetValue(j) + "' where srno =" + (i + 1);
cmd.ExecuteNonQuery();
cmd1.ExecuteNonQuery();
}
}
Thanks,
JMO
-- modified at 9:33 Monday 22nd January, 2007
|
|
|
|
 |