Advertisement

02.26.2008 at 06:25AM PST, ID: 23193536
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

Importing a CSV file to a multidimensional Array

Asked by sebadlington in Active Server Pages (ASP), JavaScript, Scripting Languages

Tags: ,

Hi,

 I am trying to import a csv file into an array - ultimately I will be inserting it into a database but I first want to process it. The csv file is an EDI message broken up into sections. 1 header line, x amount of detail lines and 1 footer line all this is delimited by a $. So:

H$Company Name$5010251000009$$$$$$$$
X$ADDITIONAL INFORMATION:$*** PLEASE NOTE DELIVERY ADDRESS ***$IN CASE OF ORDER QUERY$PLEASE TELEPHONE 0845 6115999$$$$$$
X$IN CASE OF DELIVERY QUERY$PLEASE TELEPHONE 01924 999999$ATTN: ORDER DEPARTMENT. -- DELIVERY CONF$IRMED FOR 11.30 ON  7/02/08 --$$$$$$
X$PLEASE NOTE THAT THIS BOOKING IN TIME MU$ST BE STRICTLY ADHERED TO.$VEHICLES ARRIVING EITHER EARLY OR LATE W$ILL BE ASKED TO WAIT FOR THE$$$$$$
X$NEXT AVAILABLE SLOT.$SUBJECT TO Company Name TERMS AND CONDITION$$$$$$$$
D$9744005$080204$080207$5010251999744$1$5010251015574$0000000012$0000001260$$
T$0001$5010251000006$$$$$$$$
H$Company Name$5010251000009$$$$$$$$
X$ADDITIONAL INFORMATION:$*** PLEASE NOTE DELIVERY ADDRESS ***$IN CASE OF ORDER QUERY$PLEASE TELEPHONE 0845 61159999$$$$$$
X$IN CASE OF DELIVERY QUERY$PLEASE TELEPHONE 01924 999999$ATTN: ORDER DEPARTMENT. -- DELIVERY CONF$IRMED FOR 09.00 ON  7/02/08 --$$$$$$
X$PLEASE NOTE THAT THIS BOOKING IN TIME MU$ST BE STRICTLY ADHERED TO.$VEHICLES ARRIVING EITHER EARLY OR LATE W$ILL BE ASKED TO WAIT FOR THE$$$$$$
X$NEXT AVAILABLE SLOT.$SUBJECT TO Company Name TERMS AND CONDITION$$$$$$$$
D$9744006$080204$080207$5010251999744$1$5010669950030$0000000024$0000000280$$
T$0001$5010251000006$$$$$$$$

this comprises 2 seperate orders - the H - denotes the header - the X is the details and the D is the footer

I've managed to import the file into a single array using the code below, but I need to be able to loop through each element and perform a function depending which column it is (all those numbers are dates, order references, delivery times, product codes etc in a fixed order)

this is the code

InputCSV = "import.csv"
Delimiter = "$"

Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

If objFSO.FileExists(file) then
 Dim objFile
 Set objFile = objFSO.GetFile(file)
 Dim iFileSize
 iFileSize = objFile.Size

 If iFileSize > 0 Then
   Set objTextStream = objFSO.OpenTextFile(file  ,1)
   ReadFile = objTextStream.ReadAll
   objTextStream.Close
   Set objTextStream = Nothing    
 Else
   ReadFile = ""

 End if
else
   ReadFile = "Error Reading File " & file
   Response.write "Error Reading File" & InputCSV & vbCrLf & vbCrLf
   errflag = 1
end if

End Function


Response.write "Import started for: " & InputCSV & vbCrLf & vbCrLf& "<br>"

CSVData2 = ReadFile(HTMLRoot & "\uploads\" & InputCSV )


CSVData3 = replace(CSVData2,chr(34),"")
CSVData = replace(CSVData3,chr(39),"")
CSVData_Lines = Split(CSVData,VbCrLF)

For x = 0 To UBound(CSVData_Lines)-1

CSVData_Lines2(x) = Split (CSVData_Lines(x), Delimiter) //' this is me trying to create multi array

//'InsertData = Replace(CSVData_Lines(x) , Delimiter, " - ")  //' this works to display the single array
//'Response.Write InsertData
//'Response.Write "<BR>"

Next

//'testtxt = Replace(CSVData_Lines2(1,1) , Delimiter, " - ")
//'Response.Write CSVData_Lines2(0,0)


thanks

Seb
Start Free Trial
[+][-]02.26.2008 at 07:15AM PST, ID: 20984989

View this solution now by starting your 14-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Active Server Pages (ASP), JavaScript, Scripting Languages
Tags: ASP VBSCRIPT, IE6 & 7
Sign Up Now!
Solution Provided By: mgfranz
Participating Experts: 2
Solution Grade: B
 
 
[+][-]02.26.2008 at 07:32AM PST, ID: 20985159

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.26.2008 at 08:26AM PST, ID: 20985793

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.26.2008 at 01:34PM PST, ID: 20989125

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 14-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]02.26.2008 at 04:05PM PST, ID: 20990247

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.26.2008 at 07:18PM PST, ID: 20991099

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.27.2008 at 02:13AM PST, ID: 20992731

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-43 / EE_QW_2_20070628