Page 1 of 1

import contents of the files to csv

Posted: Thu Jun 09, 2011 6:58 pm
by kootik
i have such csv file and i want to ask how can i replace det-text column with the content from the file
and each new det-text column replace with the content from the next file

IE_XML_ID;IE_NAME;IE_ID;IE_ACTIVE;IE_ACTIVE_FROM;IE_ACTIVE_TO;IE_PREVIEW_PICTURE;IE_PREVIEW_TEXT;IE_PREVIEW_TEXT_TYPE;IE_DETAIL_PICTURE;IE_DETAIL_TEXT;IE_DETAIL_TEXT_TYPE;IE_CODE;IE_TAGS;IC_GROUP0;IC_GROUP1;IC_GROUP2
27;tablename;27;Y;;;;anonce;html;;det-text;html;;;comcurse;;
28;tablename;28;Y;;;;anonce;html;;det-text;html;;;comcurse;;
29;tablename;29;Y;;;;anonce;html;;det-text;html;;;comcurse;;
30;tablename;30;Y;;;;anonce;html;;det-text;html;;;comcurse;;
31;tablename;31;Y;;;;anonce;html;;det-text;html;;;comcurse;;
32;tablename;32;Y;;;;anonce;html;;det-text;html;;;comcurse;;
33;tablename;33;Y;;;;anonce;html;;det-text;html;;;comcurse;;
34;tablename;34;Y;;;;anonce;html;;det-text;html;;;comcurse;;
35;tablename;35;Y;;;;anonce;html;;det-text;html;;;comcurse;;


p/s maybe somebody can help

Re: import contents of the files to csv

Posted: Fri Jun 10, 2011 5:22 pm
by kootik

Code: Select all

Выбор полей CSV:CSV поле 11 .. поле 11
|  [X] Process fields individually
|    [X] Exclude delimiter
|      [X] Exclude quotes (if present)
|  Delimiter Type: 2
|  Custom delimiter: 
|  [X] Has Header
|
|--Comment...
|     The following pattern match removes any quotes surrounding the filename, and also removes the trailing comma, if any
|   
|--** БЛОКИРОВАНО ** Схема ["?([^",]*)"?,?] с [$1]
|     [ ] С учетом регистра
|     [ ] Полное слово
|     [ ] Замена с учетом регистра
|     [ ] Подсказка для замены
|     [ ] Без подсказки если идентично
|     [ ] Только первое
|     Максимальный размер буфера текста 4096
|   
+--VBScript сценарий  Длительность: 10000 миллисекунд
      'Read in a file specified in a field
      
      Const OpenFileForReading = 1 
      Dim fso, TextStream
      
      function processLine(line, EOL)
      
        Dim fileContents
        Dim filename
      
        filename = "e:\444\edu\" & line
      
        'ignore the error if the file is not found
        on error resume next
        fileContents = "** " & filename & " was not found **"
      
        'read what's in the file
        Set TextStream = fso.OpenTextFile( filename, _
          OpenFileForReading)
        fileContents = TextStream.ReadAll
        TextStream.close
      
        processLine = fileContents & EOL
      
      end function
      
      
      'Called at the start of a processing job -
      'perform one-time initialisation here
      sub startJob()
        Set fso = CreateObject("Scripting.FileSystemObject")
      end sub
      
      
      'Called at the end of a processing job -
      'destroy any declared objects here
      sub endJob()
        'do nothing
      end sub
      
      
      'Called before each file is opened -
      'perform per-file initialisation here
      function startFile()
        startFile = ""
      end function
      
      
      'Called before each file is closed -
      'flush all pending file output here
      function endFile()
        endFile = ""
      end function
    

Re: import contents of the files to csv

Posted: Tue Jun 14, 2011 4:48 pm
by DataMystic Support
In the script filter folder there is a filter called replace filename with file contents.fll

Basically you use a restriction to provide it with just the filename, then use the script below to insert the file. You might need to replace the ';' in the filename with a '.' first.

Code: Select all

'Read in a file specified in a field

Const OpenFileForReading = 1 
Dim fso, TextStream

function processLine(line, EOL)

  Dim fileContents
  Dim filename

  filename = "c:\" & line

  'ignore the error if the file is not found
  on error resume next
  fileContents = "** " & filename & " was not found **"

  'read what's in the file
  Set TextStream = fso.OpenTextFile( filename, _
    OpenFileForReading)
  fileContents = TextStream.ReadAll
  TextStream.close

  processLine = fileContents & EOL

end function


'Called at the start of a processing job -
'perform one-time initialisation here
sub startJob()
  Set fso = CreateObject("Scripting.FileSystemObject")
end sub


'Called at the end of a processing job -
'destroy any declared objects here
sub endJob()
  'do nothing
end sub


'Called before each file is opened -
'perform per-file initialisation here
function startFile()
  startFile = ""
end function


'Called before each file is closed -
'flush all pending file output here
function endFile()
  endFile = ""
end function

Re: import contents of the files to csv

Posted: Wed Jun 15, 2011 5:35 am
by kootik
thanks for help i have already makeit myself

with this script but i made some changes

i use restrict tab to specify column

in this column i inserted name of files
like this
file.html
file2.html
file3.html

and set my csv file in files tab

and after that

all 1000 files was inserted in my csv file

thats how i inserted 1000 in my csv file and than import
it my cms site

p/s(it is need to dulicate " and convert text " to html code)


pps sory for my english

Re: import contents of the files to csv

Posted: Wed Jun 15, 2011 12:01 pm
by DataMystic Support
It sounds like everything is ok now?

Re: import contents of the files to csv

Posted: Thu Jun 16, 2011 12:23 pm
by kootik
yes thanks for you best programm in the world