ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Closed Thread
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 8th, 2005, 10:21 AM
bawaite bawaite is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 84 bawaite User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 50 m 45 sec
Reputation Power: 5
Tab delimited input into database

Good Day

I am working on a project that requires inserting content from tab delimited files into a access database, the files are contained in a zip file that is sent from a different server every night with a the name of the zip file being the date it was sent on (02-07-05.zip), the files in the zip file are tab delimited files, but they are called;
- 02-07-05.M
- 02-07-05.O
- 02-07-05.P

Each file contants the original column information that of course will not have to be entered.

I have created 3 tables in my database to store this information called members, offices, and people. The content in each file are not consistent, for example one of the column are called age, the value rage from 16, 24, 30 and OLD (it is in text form) also some column values are left blank.

Each time I need to insert the content into the database (every night) the old content has to be completed removed and then re-entered, because items are removed and new items are entered frequently.

Any Suggestions


Review of what needs to be done:
- Zipped file has to be unzipped
- open each file
- wipe old data and database
- enter content from files (allow for empty data)
- remove unzipped files from server
- done every night around midnight
(Run the script as a schedule task)
- try to keep the load on server low


I have tried many different processes for inserting the data from the file but my mane problem that I have come across is the empty values.

Any help you can give will be greatly appreciated.

Reply With Quote
  #2  
Old February 8th, 2005, 11:03 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,689 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 33 m 51 sec
Reputation Power: 53
All you need to do is loop over the tab-delimited data, using the tab character as the delimiter for a list loop. Then each iteration of the loop is one tab-delimited line of the file. Insert each one into the database.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old February 8th, 2005, 12:19 PM
bawaite bawaite is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 84 bawaite User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 50 m 45 sec
Reputation Power: 5
How can I go about doing that, without putting too much load on the server, there will be about 200 results that will have to be added every night, would not create a new connection to the database every time I run the CFQUERY function?

Reply With Quote
  #4  
Old February 8th, 2005, 01:37 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,689 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 33 m 51 sec
Reputation Power: 53
No, ColdFusion maintains database connections unless you have explicitly unchecked that box when you created the datasource. And no, running 200 insert statements will not do anything to your server. If it was 20,000 inserts then you'd have to worry.

Reply With Quote
  #5  
Old February 9th, 2005, 07:18 AM
bawaite bawaite is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 84 bawaite User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 50 m 45 sec
Reputation Power: 5
ok thats good then, one last question concerning this item, some of the colums contain empty values and useing this coding setup:

Code:
<cfloop index="record" list="#fileData#" delimiters="#chr(10)##chr(13)#">
          <cfquery name="qryInsert" datasource="whatever">
          INSERT INTO tablename (COL1, Col2, Col3, Col4, Col5, Col6, Col7, Col8, Col9, Col10, Col11, Col12)
          VALUES (
               <cfqueryparam value="#listgetat(record,1,chr(9))#" cfsqltype="cf_sql_varchar">,
               <cfqueryparam value="#listgetat(record,2,chr(9))#" cfsqltype="cf_sql_varchar">,
               <cfqueryparam value="#listgetat(record,3,chr(9))#" cfsqltype="cf_sql_varchar">,
               <cfqueryparam value="#listgetat(record,4,chr(9))#" cfsqltype="cf_sql_numeric">,
               <cfqueryparam value="#listgetat(record,5,chr(9))#" cfsqltype="cf_sql_numeric">,
               <cfqueryparam value="#listgetat(record,6,chr(9))#" cfsqltype="cf_sql_numeric">,
               <cfqueryparam value="#listgetat(record,7,chr(9))#" cfsqltype="cf_sql_numeric">,
               <cfqueryparam value="#listgetat(record,8,chr(9))#" cfsqltype="cf_sql_numeric">,
               <cfqueryparam value="#listgetat(record,9,chr(9))#" cfsqltype="cf_sql_numeric">,
               <cfqueryparam value="#listgetat(record,10,chr(9))#" cfsqltype="cf_sql_numeric">,
               <cfqueryparam value="#listgetat(record,11,chr(9))#" cfsqltype="cf_sql_numeric">,
               <cfqueryparam value="#listgetat(record,12,chr(9))#" cfsqltype="cf_sql_varchar">
          )
          </cfquery>
     </cfloop>


the last value returns an error saying that the list only has 11 items, I am sure that I have done this before, but how could I do a simple check to see if each list item has a value?

Thank you

Reply With Quote
  #6  
Old February 9th, 2005, 07:30 AM
Shane_Z Shane_Z is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Location: In denial
Posts: 22 Shane_Z User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 57 m 52 sec
Reputation Power: 0
Send a message via MSN to Shane_Z
you could get the ListLen to get the number of elements in the list. if its less than 12 then do your error checking stuff.

Reply With Quote
  #7  
Old February 9th, 2005, 08:02 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,689 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 33 m 51 sec
Reputation Power: 53
But if the list has only 11 entries, you will probably need to check every one of the list positions to determine which one is missing, otherwise you'll always be assuming that it's the last one in the list when it may in fact not be.

Reply With Quote
  #8  
Old February 9th, 2005, 10:25 AM
bawaite bawaite is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 84 bawaite User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 50 m 45 sec
Reputation Power: 5
This should be a simple question but how would I be able to check all of them to ensure each colum had a value, kiteless.

Reply With Quote
  #9  
Old February 10th, 2005, 03:56 AM
Black Adder Black Adder is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 16 Black Adder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 47 m 27 sec
Reputation Power: 0
ColdFusion ignores empty lis elements. So if your list contains of 3 elements and one of them is empty (i.e. element1,,element2) then ColdFusion would threat that as an 2-elemental list.
Maybe replacing the empty elements in the list with "", or whatever empty value would be satisfying for your need, could help you out.

Reply With Quote
  #10  
Old February 10th, 2005, 08:12 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,689 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 33 m 51 sec
Reputation Power: 53
There are also some custom list functions at cflib.org that deal with lists without merging empty list elements together as the built-in CFML list functions do.

Reply With Quote
  #11  
Old February 10th, 2005, 02:43 PM
bawaite bawaite is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 84 bawaite User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 50 m 45 sec
Reputation Power: 5
I found what I needed to do thank you.

Reply With Quote
Closed Thread

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Tab delimited input into database


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT