Loading...
 
Features / Usability

Features / Usability


Re: Re: using TXT files as content ?

posts: 1563 Germany

Hi smallhagrid,

maybe you are giving up too quickly?

I think a solution for your problem is not so difficult, as it sounds upfront - maybe it is quite simple.

You got a good bunch of replies and all what is going, is a brainstorming to find a solution for your idea, which is in no kind seen as nonsense or such.

There is no routine yet to import textfiles into Tiki wikipages / Tiki wikipage mysql-tables.

If you want to make people becoming interested in this problem and elaborate a solution together with you, you should not stamp on the floor and head off because you didn't get a 24 hr solution donated.

I believe, this must be possible to be done with a bit of Linux and a bit of MySQL knowledge - it is just plain text!

Maybe you head off to the next forum/project/community, but maybe same time I have a .txt to wiki solution in just a few weeks, because ... just because.
Btw. I have a few .txt files aswell and I start to use Tiki as online PIM aswell since a while.

And yes, you are right about the services - I want my stuff on my own private host aswell and design everything around my needs!

If you are already discouraged, I tell ya "thx, that you called in and left a very good idea - simple but I might not have been thinking on that for a long time"

So back on track to find a solution together?



The approach of Dokuwiki sounds - as you discribe it - to make the software kind of "understand" the .txt file.

I do not know much about Dokuwiki and would have to ask one of the lads I met at the WikiFests in Berlin and in Strasbourg.

But we are on Tiki right now and my approach would be different:

basically i would try to "convert" a single .txt file into a Tiki mySQL table just by adding a few characters into the textfile and then rename it into a .csv file.

I recently had a similar problem as I had to rename a domain name into a subdomainname throughout hundrets of .html and .php files and finally solved that with one line of code in my linux shell.

I even did not need to download the files from the server, as I just made it there via ssh access - three days of research and trial and about 5 minutes for the initial job.

It was just necessary to grap the string (REGEX, Regular expression) in the file with the 'find' command and execute the renaming with the 'sed' command.

would be s.th. like:
please mind that this is not yet working code, but just thoughts to find the right algorythm

Copy to clipboard
find parameter regex -exec sed parameter regex


This as said could be done for hundrets of files in one action.

Mind now, that you can import and export mySQL tables not only as .sql files, but also as .csv files.

.csv files are nothing else than renamed .txt files

renaming a hundret .txt into .csv would lead to a shell command like:
please mind that this is not yet working code, but just thoughts to find the right algorythm

Copy to clipboard
find parameter .txt -exec rm .csv


or similar -> it must be not hard to find the right line of code in the linux forums out there in the www

Bringing this together we have to look how a Tiki wikitable is looking as .csv file - actually all wikipages are store in one table, one line for each wikipage - mind the string " " marks a filed and , divides two fields of one line of the table:

Copy to clipboard
"1","HomePage","7","HERE IN THIS FIELD IS THE ACTUAL WIKISYNTAX, RESPECTIVELY THE CONTENT OF YOUR .TXT FILE",,"1330179298","Tiki initialization","1","0","admin","0.0.0.0",,NULL,NULL,NULL,NULL,NULL,NULL,"admin", "4175","de",,"0","1330179298","n",,NULL,NULL


analyse the first part:

"1","HomePage","7","WIKITEXT"

  • "1" is the Id of the page - for an import this field should mostlikely contain a zero (0) to be granted a new Id number -> we have to ask in the Tiki dev list for this detail.
  • "HomePage" the name of the wiki page -> that coul become the real problem, because we have to convert the .txt files in a way, that the filename of the.txt will finally become the second field of the contained table in the .csv
  • "7" is the number of hits, can be 0 aswell
  • "WIKITEXT" is the content of the .txt file and will become the content of the wikipage


analyse the second part:

"WIKITEXT",,"1330179298","Tiki initialization","1","0","admin","0.0.0.0",,NULL,NULL,NULL,NULL,NULL,NULL,"admin",
"4175","de",,"0","1330179298","n",,NULL,NULL

  • "WIKITEXT" as above
  • empty field description
  • "1330179298" date of last modification
  • and so on ...


in fact everything after "Wikitext" can be the same for each .txt file



How the Code must look like now?
please mind that this is not yet working code, but just thoughts to find the right algorythm

Copy to clipboard
find .txt $allcontent -exec sed "0","$filename","0","$allcontent


and after that
please mind that this is not yet working code, but just thoughts to find the right algorythm

Copy to clipboard
find .txt $allcontent -exec sed $allcontent",,"1330179298","Tiki initialization","1","0","admin","0.0.0.0",,NULL,NULL,NULL,NULL,NULL,NULL,"admin", "4175","de",,"0","1330179298","n",,NULL,NULL


Now we would need to find a command or a little shell srcipt, that merges all contents of several files into one single file - for each .txt file a next line and write the result into another directory

after that we move to the directory and rename the file:

Copy to clipboard
cd path/to/the/directory mv mynewfile.txt mynewfile.csv


In principle this should be all - now we could try and import the .csv file into Tiki database and should have a good bunch of new wikipagges - all pagenames representing the original filenames.



To bring this to an extend:

If you have a certain system im marking your headlines, notes, warnings etc.you could even partially convert the content of your textfiles into Tikis WikiSyntax before you convert the .txt files into tables.

Copy to clipboard
For example, if your headlines would be like this: headline ******** or /*headline*/ You just make them !headline and your new wikipage is even a bit formatted.


So, now I put my ideas forward to discussion - all reply, critique, suggestions are appreciated.

Cheers

--ToF

There are no comments at this time.