hi i have a array which is set from a csv file, and then inserted into a table.
the problem i am having is the surname which is the first array is entering a
carrage return before the text.
how can i remove this carrage return?
<!--- expected data fields ; Firstname, Surname, Phone, Group, ID --->
<cfset columncount = 7>
<cffile action="read" file="#currentdir#/#GetUser.CsvMatch#.csv"
variable="datafile">
<cfset counter = 1>
<cfloop index="datarec" list="#datafile#" delimiters="#chr(13)#">
<cfif counter gt 1>
<!---use ListToArray function with comma delimiter for each data record--->
<cfset dataArray = ListToArray(datarec,chr(44))>
<cfif ArrayLen(dataArray) eq columncount >
<cfquery name="INSERT" datasource="#application.ds#">
insert into player_table
(PlayerSurname, PlayerFirstName, PlayerPhone, Team, Class, App_ID, ClubID)
values
('#dataArray[1]#','#dataArray[2]#','#dataArray[3]#','#dataArray[4]#','#dataArray
[5]#','#dataArray[6]#',#getuser.clubID#)
</cfquery>
Dan Bracuk - 15 Sep 2007 11:10 GMT
Try it without an array. Loop through your datarec list instead. If you still
get the carraige return, use the replace function to get rid of it. You've
shown in your posted code that you know how to do that.
KeithLaw999 - 16 Sep 2007 10:26 GMT
ok i need the array as i use it later in my code, so i tried this
'#replace(dataArray[1], '#chr(13)#', '', 'all')#'
but the carrage return stil appears before the text, any ideas how i can
replace this?
GArlington - 18 Sep 2007 10:24 GMT
> ok i need the array as i use it later in my code, so i tried this
>
> '#replace(dataArray[1], '#chr(13)#', '', 'all')#'
>
> but the carrage return stil appears before the text, any ideas how i can
> replace this?
Replace(dataArray[1], chr(13), "", "ALL");
Replace(dataArray[1], chr(10), "", "ALL");