ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

Converting Spreadsheet to Table in forum

<< < (9/9)

Target:
you could also do this in Excel using concatenation - this is perhaps not as elegant as some of the other solutions but it's quick and easy and it doesn't have any dependancies...

formula would look something like ="<tr><td>"&A1&"</td><td>"&B1&"</td><td>"&C1&"</td></tr>"

copy and paste the result into your forum (you'll need to add opening and closing table tags) and your done

you could also put your tags into a cell and reference that cell in your formula to save yourself some typing (the cell refs will need to be absolute)

tomos:
in which folder have you installed your sed.exe? Lets assume it is in "C:\Program Files\Gnu\Sed\", than you should change the bat-file like this to ensure your sed.exe is found (this is what I meant by "change the path"):

--- ---@echo off
set infile=%1%
"C:\Program Files\Gnu\Sed\sed.exe" -e "s/;/\[\/td\]\[td\]/g" "%infile%" > temp1.txt
"C:\Program Files\Gnu\Sed\sed.exe" -e "s/$/\[\/td\]\[\/tr]/g" temp1.txt > temp2.txt
"C:\Program Files\Gnu\Sed\sed.exe" -e "s/^/\[tr\]\[td\]/g" temp2.txt > temp1.txt
echo [table] > table.txt
type temp1.txt >> table.txt
echo [/table] >>  table.txt
del temp1.txt
del temp2.txt
-crono (March 02, 2009, 06:55 PM)
--- End quote ---

It finds SED all right now (online armor requested permission to start it) but: a command window opens, closes and nothing else happens ...
the batch file is correct, I've checked it again and again
I copied sed.exe path into file in quotes as you show - it was in C:\Program Files\GnuWin32\bin\sed.exe (just in case)

command window said it couldnt find file path - broke it up in two parts actually, so I moved both files/folders up the tree a bit but now the command window shows completely blank
Is it important where the files are, and where in relation to each other ?

crono:
Hello again,


--- ---@echo off
REM File which is dropped onto the Batch File
set infile=%1%

REM change the WorkingDirectory to the folder which contains the dropped file
REM The new file table.txt will be created in the same folder as the source file
cd /d %1\..

REM Do the transformation
"C:\Program Files\GnuWin32\bin\sed.exe" -e "s/,/\[\/td\]\[td\]/g" "%infile%" > temp1.txt
"C:\Program Files\GnuWin32\bin\sed.exe" -e "s/$/\[\/td\]\[\/tr]/g" temp1.txt > temp2.txt
"C:\Program Files\GnuWin32\bin\sed.exe" -e "s/^/\[tr\]\[td\]/g" temp2.txt > temp1.txt

REM Build the output
echo [table] > table.txt
type temp1.txt >> table.txt
echo [/table] >>  table.txt

REM Cleanup
del temp1.txt
del temp2.txt

I changed the script to work with comma as separator - the other versions used ";". If it does not work add "PAUSE" (without the quotes) at the end of the batch file (it prevents the command window from being closed) and post the contents and maybe a demo file which should be transformed.

bye :)

tomos:
Hello again,
...

I changed the script to work with comma as separator - the other versions used ";". If it does not work add "PAUSE" (without the quotes) at the end of the batch file (it prevents the command window from being closed) and post the contents and maybe a demo file which should be transformed.

bye :)
-crono (March 03, 2009, 05:12 PM)
--- End quote ---
hi crono
that's working now :Thmbsup:
thanks!

the original script didnt work for me with ";" as seperator either (just tried today) so happy to get this one
many thanks again, tom

Navigation

[0] Message Index

[*] Previous page

Go to full version