SEO | Link Popularity | Search Engine Consulting | SEO Tutorial | SEO Tools | SEO Forum
Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-28-2007, 02:15 AM
TommyG TommyG is offline
SEO Junior
 
Join Date: Mar 2007
Posts: 26 TommyG is on a distinguished road
Import http Live CSV to DB ???

Is it possible to create a script to import the contence os a CSV or TXT file that is hosted live on the internet straight in to your database without first having to save the file to your computer ?????

If so please could some one point me in the right direction so that i can do it...
__________________
MySite:- www.three-mobile-phones.com/seoguy.html
Reply With Quote
  #2  
Old 04-11-2007, 04:26 PM
BSolveIT's Avatar
BSolveIT BSolveIT is offline
SEO
 
Join Date: May 2005
Location: England, UK
Posts: 621 BSolveIT has a spectacular aura aboutBSolveIT has a spectacular aura about
Send a message via MSN to BSolveIT
Hi TommyG

Yes, it's quite simple really.

Code:

Dim URL = "http://www.xyz.com/somefile.txt"
Dim objXMLHTTP
Set objXMLHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP")
objXMLHTTP.Open "GET", URL, False
objXMLHTTP.Send

IF objXMLHTTP.statusText = "OK" THEN
   txtFile = objXMLHTTP.responseText
   '
   '*** Process the content of the file any way you like
   '
END IF

'*** Clean up!
Set objXMLHTTP = nothing


The URL can point to any type of file at all, including XML, or even HTML.

You could also do this in Javascript, but you'll get into security context issues if the file being retrieved is not on the local domain - although it's very easy to get around that using a server based proxy script. i.e. Use javascript to call your usual ASP page (which will do the same thing as above), but return the results back to the calling Javascript. You do it that way because the server isn't security restricted.

Doing it this latter way also means you can achieve the desired results without a page refresh. Its actually AJAX - it's very simple.

If you have any problems, let me know.



- BSolveIT
Reply With Quote
  #3  
Old 04-12-2007, 01:04 AM
TommyG TommyG is offline
SEO Junior
 
Join Date: Mar 2007
Posts: 26 TommyG is on a distinguished road
Nice One BSolveIT, I'll have a go with that today and let you know how i get on

Cheers again!!!
__________________
MySite:- www.three-mobile-phones.com/seoguy.html
Reply With Quote
  #4  
Old 04-12-2007, 01:29 AM
TommyG TommyG is offline
SEO Junior
 
Join Date: Mar 2007
Posts: 26 TommyG is on a distinguished road
Hi BSolveIT, I am hoping you can give me a little more help.

i have 2 live feeds i would like to be able to import in to my database either automaticly or at least without having to go threough all the rigmoral of saving files down and uploading them to my server.

the 2 files are different
1 - http://summitfeed.co.uk/three/three-affil.txt
2 - http://www.three-mobile-phones.com/feeds/bestdeals.csv

I just dont know where to begin with the coding to insert the data from these files in to my DB

specificly How do i split the "objXMLHTTP.responseText" in to usable columns and rows?

My tese page is http://www.three-mobile-phones.com/_Untitled-1.asp

and at present i am experimenting with the code you gave me to see what i can do.

Can you point me in the right direction of any tutorials or similar threads that could help me ???
__________________
MySite:- www.three-mobile-phones.com/seoguy.html
Reply With Quote
  #5  
Old 04-12-2007, 03:17 AM
BSolveIT's Avatar
BSolveIT BSolveIT is offline
SEO
 
Join Date: May 2005
Location: England, UK
Posts: 621 BSolveIT has a spectacular aura aboutBSolveIT has a spectacular aura about
Send a message via MSN to BSolveIT
Well, looking at the txt file (I couldn't access the csv file), it appears quite straight forward again. There willl be a few different ways to do this of course, but it all boils down to string manipulation.

Are you familiar with the SPLIT function? Using the SPLIT function, you will be able to read the entire file into an array of lines, then further split each line into an array of elements. Then you'll just need to iterate through and save the values to your database.

Here's an excellent example / tutorial:
http://www.devx.com/asp/Article/16806

Reply With Quote
  #6  
Old 04-12-2007, 03:19 AM
BSolveIT's Avatar
BSolveIT BSolveIT is offline
SEO
 
Join Date: May 2005
Location: England, UK
Posts: 621 BSolveIT has a spectacular aura aboutBSolveIT has a spectacular aura about
Send a message via MSN to BSolveIT
Sorry, I forgot to mention, your going to SPLIT the file into it's lines by splitting on the return character (vbCRLF), but each line will be split into it's elements not on the space character, but on the tab character (vbTAB).
Reply With Quote
  #7  
Old 04-12-2007, 06:38 AM
TommyG TommyG is offline
SEO Junior
 
Join Date: Mar 2007
Posts: 26 TommyG is on a distinguished road
Hi BSolveIT,

I have never used the SPLIT function before but i am going to have a go at that tutorial now.

The other feed is in my own site so i put a password protect on it, I'll take it off now so you can have a look
__________________
MySite:- www.three-mobile-phones.com/seoguy.html
Reply With Quote
  #8  
Old 04-12-2007, 06:46 AM
BSolveIT's Avatar
BSolveIT BSolveIT is offline
SEO
 
Join Date: May 2005
Location: England, UK
Posts: 621 BSolveIT has a spectacular aura aboutBSolveIT has a spectacular aura about
Send a message via MSN to BSolveIT
Hi Tommy

Ok, I've looked at the CSV now too. You'll be able to handle it in almost the exact same way. After splitting on the vbCRLF characters to get the lines, split each line at the comma+space. e.g. elements_array = SPLIT(row, ", ")

You'll crack it in super fast time I'm sure.

Let me know how you get on, or if you need more help.

Reply With Quote
  #9  
Old 04-12-2007, 07:13 AM
TommyG TommyG is offline
SEO Junior
 
Join Date: Mar 2007
Posts: 26 TommyG is on a distinguished road
Cheers Mate!!!
__________________
MySite:- www.three-mobile-phones.com/seoguy.html
Reply With Quote
  #10  
Old 04-13-2007, 12:56 AM
TommyG TommyG is offline
SEO Junior
 
Join Date: Mar 2007
Posts: 26 TommyG is on a distinguished road
Nice One BSolveIT, I am getting the hang of this now,

I think someone tried to explain this to me a while ago but at the time it made No sence at all.

I havent quite done all i want to do but you have deffinately put me on to the right track.

One more question,

Imagine i create scripts to update my database, do you know what would be the way to make these scripts run automaticly in a sequence say either at a set time interval or when the input feed changes (You mentioned in in the first post i think?)?
__________________
MySite:- www.three-mobile-phones.com/seoguy.html
Reply With Quote
Reply


Thread Tools
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
Forum Jump


Login/Register
User Name
Password
Remember Me?

Forum Links
Forum Home
SEO Forum
Internet Marketing Forum
Web Design Forum
Web Hosting Forum
Programming Forum
SEO Chat

Quick Links
Forum Home
New Posts
Mark Forums Read
Open Buddy List
User Control Panel
Edit Avatar
Edit Profile
Edit Options
Miscellaneous
Subscribed Threads
My Profile

Search Forums

Advanced Search
All times are GMT -8. The time now is 11:15 PM.


Powered by: vBulletin Version 3.0.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.