Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Saturday, May 18, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Data & Imports Forums - SalesLogix Imports
Forum to discuss general SalesLogix import and data migration topics. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Imports | New ThreadView:  Search:  
 Author  Thread: I am looking for an example to import directly from a CSV file.
Lawrence Reid
Posts: 63
 
I am looking for an example to import directly from a CSV file.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 09 Nov 07 7:26 AM
This CSV file contains text, numbers, and date fields. I found an example to import from an Excel file here that works, but I want to avoid having to open Excel first to convert the CSV file to XLS. Thanks in advance for you assistance.
[Reply][Quote]
Mike Spragg
Posts: 1226
Top 10 forum poster: 1226 posts
 
Re: I am looking for an example to import directly from a CSV file.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Nov 07 5:18 AM
You can do this directly - not sure what you mean above as its conflicting. The file either starts as CSV (only) or is XLS and Excel is used to convert it back to CSV.
[Reply][Quote]
Phil Parkin
Posts: 819
Top 10 forum poster: 819 posts
 
Re: I am looking for an example to import directly from a CSV file.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 11 Nov 07 4:59 PM
So are you just looking for sample code that imports data from a CSV file into a SLX table?
[Reply][Quote]
Lawrence Reid
Posts: 63
 
Re: I am looking for an example to import directly from a CSV file.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 11 Nov 07 5:06 PM
Yes, I have small csv file that needs to be imported by a button in SLX. The file has a ID as a text field without quotes, followed by some money or number fields and the last field is a date field formatted in quotes like "9/30/2007".

Any assistance is greatly appreciated.
[Reply][Quote]
Lawrence Reid
Posts: 63
 
Re: I am looking for an example to import directly from a CSV file.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 11 Nov 07 5:28 PM
Yes, I have small csv file that needs to be imported by a button in SLX. The file has a ID as a text field without quotes, followed by some money or number fields and the last field is a date field formatted in quotes like "9/30/2007".

I only have a sample to import an XLS file and not a CSV file. The source can only export as fixed width, Tab delimited or CSV. I am trying to avoid having to convert from XLS to CSV in Excel by reading the CSV file directly.

Any assistance is greatly appreciated.
[Reply][Quote]
Lawrence Reid
Posts: 63
 
Re: I am looking for an example to import directly from a CSV file.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 11 Nov 07 5:28 PM
Yes, I have small csv file that needs to be imported by a button in SLX. The file has a ID as a text field without quotes, followed by some money or number fields and the last field is a date field formatted in quotes like "9/30/2007".

I only have a sample to import an XLS file and not a CSV file. The source can only export as fixed width, Tab delimited or CSV. I am trying to avoid having to convert from XLS to CSV in Excel by reading the CSV file directly.

Any assistance is greatly appreciated.
[Reply][Quote]
Phil Parkin
Posts: 819
Top 10 forum poster: 819 posts
 
Re: I am looking for an example to import directly from a CSV file.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 11 Nov 07 8:54 PM
Create your connection & read from file (filespec held in FilePath and Filename)

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & FilePath & ";" & _
"Extended Properties=""text;HDR=YES;FMT=Delimited"""

objRecordset.Open "SELECT * FROM [" & Filename & "]", _
objConnection, adOpenStatic, adLockOptimistic, adCmdText

Now you have a recordset and can iterate round it, creating the SLX records as you go. Make sure that you Include System: SLX Database Support in your import script.

Note: your CSV file needs fieldnames in row 1 - best to make these 'nice' - concise, no spaces & no unusual characters. These fieldnames will be inherited by the recordset.

Note 2: importing from CSV is far easier than from Excel, in my opinion. Don't even think about converting CSV to XLS format and then importing.

Note 3: if your SQL is hot, you can import directly from T-SQL using OPENROWSET. Don't do this unless you understand the synchronisation consequences (or if you have no remotes).



[Reply][Quote]
Lawrence Reid
Posts: 63
 
Re: I am looking for an example to import directly from a CSV file.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Nov 07 9:47 AM
Thanks Phil, this worked great. I just need to trap for a couple of errors caused by bad data.

I have a question about Note3. First, we currently do not have remotes. This CSV file is being imported into a staging table that would not be synced to remotes. I originally used a DTS script to import this daily, but they now want to run this any time from in SLX. Is there a way to call my DTS from inside SLX?

I just read about OPENROWSET. This looks like another way to get the CSV data into the staging table. I will test this out too.

Thanks again.
[Reply][Quote]
Phil Parkin
Posts: 819
Top 10 forum poster: 819 posts
 
Re: I am looking for an example to import directly from a CSV file.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Nov 07 4:36 PM
Check Books Online regarding the T-SQL DTSRun command - it will (in theory - never tried it) allow you to run DTS packages from SLX.

As far as OPENROWSET is concerned, here's a code snippet I got from a forum that might set you in the right direction. Obviously the appeal of this method is the ease of deployment and maintenance:

SELECT *
FROM
OPENROWSET('MSDASQL',--provider name (ODBC)
'Driver={Microsoft Text Driver (*.txt; *.csv)};
DEFAULTDIR=C:\;Extensions=CSV;',--data source
'SELECT * FROM sample.csv')

PP
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 5/18/2024 2:43:00 PM