Hi,
First make two tabels, In the example I made:
csv_naam (headers csv file)
zdev_naam (headers/fields table)
offset
readvar
Put the right data in this table like for instance:
header csv header table offset rv
SystemInformation_SerialNumber z_serienr 2 1
type z_type 1 1
MAC_Address z_mac 3 1
BIOS_InstallDate z_bios 6 1
Processor_CurrentClockSpeed(MHz) z_proc 7 1
Memory_TotalMemory(MB) z_mem 8 1
IP_Address z_ip 9 1
SystemInformation_Manufacturer z_fab 4 1
SystemInformation_Model z_model 5 1
InventoryInformation_LastScanDate z_scandatum 10 1
Then make another table with the following fields:
z_serienr
z_type
z_mac
z_bios
z_proc
z_mem
z_ip
z_fab
z_model
z_scandatum
See the code below I used:
<cfparam name="attributes.recordscheiding" default="#chr(10)##chr(13)#">
<CFPARAM name="attributes.fileupload_dirroot" default="C:\xampp\htdocs\bar\csv\files\">
<CFSETTING requesttimeout="600">
<CFSET toegevoegd=0>
<CFSET diflist="">
<CFSET Filename=' '>
<CFIF Isdefined("Form.Uploadfile") EQ "YES">
<CFIF Len(Trim(Form.UploadFile)) GT 0>
<CFFILE
ACTION= "UPLOAD"
FILEFIELD = "Form.UploadFile"
DESTINATION = "#attributes.fileupload_dirroot#"
NAMECONFLICT = "MakeUnique">
<CFSET Filename=file.Serverfile>
<CFELSE>
<!--- <CFSET Foutis="Geen file ingevoerd."> --->
<!--- error handeling --->
<cferror type = "REQUEST"
template ="../../error/request_err2.cfm">
<!--- <CFINCLUDE TEMPLATE="/systeem/foutmelding.cfm"> --->
</CFIF>
</CFIF>
<CFQUERY NAME="" DATASOURCE="">
DELETE from zen_dev
</CFQUERY>
<CFFILE ACTION="READ"
VARIABLE="Content"
FILE="#attributes.fileupload_dirroot##Filename#">
<CFSET Nerrors=0>
<CFSET content=replace(content,";;;;;;",";x;x;x;x;x;","ALL") >
<CFSET content=replace(content,";;;;;",";x;x;x;x;","ALL") >
<CFSET content=replace(content,";;;;",";x;x;x;","ALL") >
<CFSET content=replace(content,";;;",";x;x;","ALL") >
<CFSET content=replace(content,";;",";x;","ALL") >
<CFSET Totaan=ListLen(Content, "#attributes.recordscheiding#")>
<CFLOOP INDEX="Teller" FROM="1" TO="1">
<CFSET Element=ListGetAt(Content, Teller,"#attributes.recordscheiding#")>
<CFSET Expectedlen=listlen(element,";")>
<CFLOOP index="offset" from="1" TO=#listlen(element,";")#>
<CFSET Input=ListGetAt(Element, offset, ";")>
<CFQUERY NAME="getconversie" DATASOURCE="">
Select * FROM zen_1
Where offset=#offset#
</CFQUERY>
<CFIF getconversie.recordcount>
<CFIF len(trim(getconversie.csv_naam)) NEQ len(trim(input))>
</CFIF>
</cfif>
</cfloop>
</CFLOOP>
<CFQUERY NAME="conversie" DATASOURCE="">
Select * FROM zen_1
where readvar=1
order by offset
</CFQUERY>
<!--- Data inlezen --->
<CFLOOP INDEX="Teller" FROM=2 TO=#Totaan#>
<CFSET Element=ListGetAt(Content, Teller,"#attributes.recordscheiding#")>
<CFSET CurLen = ListLen(Element, ";")>
<CFIF curlen EQ Expectedlen-1>
<CFSET element="#element#;x">
</CFIF>
<CFIF curlen EQ Expectedlen-2>
<CFSET element="#element#;x;x">
</CFIF>
<CFSET CurLen = ListLen(Element, ";")>
<CFIF curlen EQ Expectedlen>
<!--- <CFOUTPUT>#content#<br></CFOUTPUT> --->
<CFOUTPUT>#curlen#<br></CFOUTPUT>
<CFLOOP query="conversie">
<CFSET temp=trim(zdev_naam)>
<CFSET "#temp#"=ListGetAt(Element, offset, ";")>
</cfloop>
<CFQUERY NAME="update" DATASOURCE="">
INSERT INTO zen_dev
(
<CFLOOP query="conversie">
#zdev_naam# <CFIF #currentrow# NEQ #conversie.recordcount#>,</cfif>
</cfloop>
)
VALUES
(
<CFLOOP query="conversie">
'#evaluate(zdev_naam)#' <CFIF #currentrow# NEQ #conversie.recordcount#>,</cfif>
</cfloop>
)
</CFQUERY>
<CFELSE>
<CFOUTPUT>len=#curlen#-#element#<br></CFOUTPUT>
</CFIF>
</CFLOOP>
<CFFILE ACTION="Delete"
FILE="#attributes.fileupload_dirroot##Filename#">
Hope this will work for you!
Grt, Kabbi