Jump to content



Photo

converting Text file into table in MySQL

c# .net

  • Please log in to reply
9 replies to this topic

#1 ramesh0123

ramesh0123

    Resident One Post Wonder

  • Joined: 25-February 13

Posted 25 February 2013 - 10:26

I have a folder that contains 50 text files ,i require a program that can read these text files and convert them into tables,i want the primary key to be the name of the text file.
//sample contents of my 1.txt file is as follows
atro
astrology
king
moon
monkey
seven
skin
All the text file contain the information in the same format


#2 Kami-

Kami-

    ♫ d(-_-)b ♫

  • Tech Issues Solved: 2
  • Joined: 28-July 08
  • Location: SandBox

Posted 25 February 2013 - 12:36

I have a folder that contains 50 text files ,i require a program that can read these text files and convert them into tables,i want the primary key to be the name of the text file.
<snip>
All the text file contain the information in the same format

So you want 50 files converting into 50 tables, with a primary key bein the name of the file? eh? *headsplodes*

#3 Kalint

Kalint

    Neowinian Senior

  • Tech Issues Solved: 2
  • Joined: 16-January 07

Posted 25 February 2013 - 14:12

red rum... Red Rum... RED RUM... RED RUM! RED RUM! RED RUM! RED RUM!

#4 Haggis

Haggis

    Neowinian Senior

  • Tech Issues Solved: 10
  • Joined: 13-June 07
  • Location: Near Stirling, Scotland
  • OS: Debian 7
  • Phone: Samsung Galaxy S3 LTE (i9305)

Posted 25 February 2013 - 14:20

yeah i am lost too

If you had one table with the text files name as the primary key

but if you had a table for each text file the primary key could not be the name of the text file as the primary key has to be unique

#5 tim_s

tim_s

    Default

  • Joined: 07-January 13
  • OS: OSX (Macbook Pro i7), Windows 7 (Gaming), Gentoo
  • Phone: Samsung Galaxy SIII, iPhone 4s

Posted 26 February 2013 - 03:46

Using a VARCHAR as a primary key would be a bad idea.

#6 Kami-

Kami-

    ♫ d(-_-)b ♫

  • Tech Issues Solved: 2
  • Joined: 28-July 08
  • Location: SandBox

Posted 26 February 2013 - 12:41

I call TROLL!

#7 Andre S.

Andre S.

    Asik

  • Tech Issues Solved: 10
  • Joined: 26-October 05

Posted 26 February 2013 - 17:51

So you require someone to do your homework? Good luck with that.

#8 tim_s

tim_s

    Default

  • Joined: 07-January 13
  • OS: OSX (Macbook Pro i7), Windows 7 (Gaming), Gentoo
  • Phone: Samsung Galaxy SIII, iPhone 4s

Posted 27 February 2013 - 03:58

Create the table + bash = 10 minutes top but why would you do this?



#9 Kalint

Kalint

    Neowinian Senior

  • Tech Issues Solved: 2
  • Joined: 16-January 07

Posted 27 February 2013 - 18:24

So you require someone to do your homework? Good luck with that.


I wouldn't believe a teacher would assign such a weird assignment like this.

#10 Hardcore Til I Die

Hardcore Til I Die

    Neowinian Senior

  • Joined: 18-February 07
  • Location: England

Posted 06 March 2013 - 13:29

The primary key has to be UNIQUE as it is what is used to reference a record in a table.

So if your file (1.txt) contained:

atro
astrology
king
moon
monkey
seven
skin

Then your table would not be able to use the file name as the primary key for each of those records because the file name doesn't change; it will always be 1.txt. Each of those seven records must have a unique primary key.