Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Create html <ui> <li> by parsing text file Post 303040268 by alcresio on Friday 25th of October 2019 07:06:18 PM
Old 10-25-2019
Create html <ui> <li> by parsing text file

Hi you all,
this is my first post in this forum. I'm italian (please forgive me) :-) so my english will fail to be correct...

Anyway, let's get straight to the point!
I have a text file like this:

Code:
  ,,,,
  Disney: 00961-002,,,,
 ,Pippo: 00531-002,,,
 ,,Pluto: 00238-002,,
 ,,Paperino: 00177-002,,
 ,,,Paperina: 00121-002,
 ,,,,Minnie: 00193-002
 ,,,Paperone: 00434-002,
 ,,,Paperoga: 00956-002,
 ,,Gambadilegno: 00715-002,,
 ,Topolino: 000078-002,,,
 ,,Basettoni: 00000-002,,
 ,,Clarabella: 00163-002,,
 ,,Paperinik: 00511-002,,
  ,,,Orazio: 00133-002,

The number of commas on the first line indicates the number of levels, those before the item indicate its depth, those after the item may be useless. The number after ":" is not relevant and should not be considered.

Well, I would like to parse it with a shell script (on Debian 8) to get as the following:


Code:
  <ul><li><span class="tf-nc">Disney</span>
       <ul><li><span class="tf-nc">Pippo</span>            
           <ul><li><span class="tf-nc">Pluto</span></li>
             <li><span class="tf-nc">Paperino</span>
               <ul> <li><span class="tf-nc">Paperina</span>
                   <ul><li><span class="tf-nc">Minnie</span></li>
                   </ul><li><span class="tf-nc">Paperone</span>
                 <li><span class="tf-nc">Paperoga</span>
                 </li></ul></li></li><li><span class="tf-nc">Gambadilegno</span></li>
           </ul></li><li><span class="tf-nc">Topolino</span>
           <ul><li><span class="tf-nc">Basettoni</span></li>
             <li><span class="tf-nc">Clarabella</span>
             <li><span class="tf-nc">Paperinik</span>             
              <ul><li><span class="tf-nc">Orazio</span></li>
              </ul></li></ul></li></ul></li></ul>

This Html code was written by hand, just to example, but in the real world, the file can contains many many items and many many “levels”¯
The final result will be, in a web browser, something like the picture you can see here: albertocortesi dot it / output.jpg


Is there anyone who could give me a little help?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How do I extract text only from html file without HTML tag

I have a html file called myfile. If I simply put "cat myfile.html" in UNIX, it shows all the html tags like <a href=r/26><img src="http://www>. But I want to extract only text part. Same problem happens in "type" command in MS-DOS. I know you can do it by opening it in Internet Explorer,... (4 Replies)
Discussion started by: los111
4 Replies

2. Shell Programming and Scripting

Create a html file if a process is running??

Hi All, I need to check for a process, if the process is running then I have to create an HTML file, say A.HTML. If the process is not running then I have to rename the existing html, say A.HTML to B.HTML so that the process which looks for the file A.HTML does not find it? How do I do... (1 Reply)
Discussion started by: Hangman2
1 Replies

3. Shell Programming and Scripting

Create multiple text file from a single text file on AIX

Hi I need to create multiple text files from onc text file on AIX. The data of text files is as below: ********************************************** ********************************************** DBVERIFY: Release 10.2.0.4.0 - Production on Tue Nov 10 13:45:42 2009 Copyright (c) 1982,... (11 Replies)
Discussion started by: lodhi1978
11 Replies

4. Shell Programming and Scripting

Linux Script create index.html file

I need a script that can do this: A script that searches all directories and subdirectories for .html files When a .html file is found it creates a index.html file in that folder. It then edits the index.html file and inserts links to all of the .html files that are in that folder into the... (5 Replies)
Discussion started by: seashell11
5 Replies

5. Programming

Parsing a Text file using C++

I was trying to parse the text file, which will looks like this ###XYZABC#### ############ int = 4 char = 1 float = 1 . . ############ like this my text file will contains lots of entries and I need to store these entries in the map eg. map.first = int and map.second = 4 same way I... (5 Replies)
Discussion started by: agupta2
5 Replies

6. Shell Programming and Scripting

Script to create a text file whose content is the text of another files

Hello everyone, I work under Ubuntu 11.10 (c-shell) I need a script to create a new text file whose content is the text of another text files that are in the directory $DIRMAIL at this moment. I will show you an example: - On the one hand, there is a directory $DIRMAIL where there are... (1 Reply)
Discussion started by: tenteyu
1 Replies

7. Shell Programming and Scripting

Parsing HTML, get text between 2 HTML tags

Hi there, I'm quite new to the forum and shell scripting. I want to filter out the "166.0 points". The results, that i found in google / the forum search didn't helped me :( <a href="/user/test" class="headitem menu" style="color:rgb(83,186,224);">test</a><a href="/points" class="headitem... (1 Reply)
Discussion started by: Mysthik
1 Replies

8. Shell Programming and Scripting

awk parsing file to create a database

Hi Guys, I have a list a hotels stored in many different text files. This list is kept in the following format: 20/03 Hotel: The Bear Hotel Honey Street Woodstock UK Tel:+44-xxxxxx Rate: 100 21/03 Hotel: The Bush Hotel Nice Street Farnham (4 Replies)
Discussion started by: freddie50
4 Replies

9. Linux

Parsing - export html table data as .csv file?

Hi all, Is there any out there have a brilliant idea on how to export html table data as .csv or write to txt file with separated comma and also get the filename of link from every table and put one line per rows each table. Please see the attached html and PNG of what it looks like. ... (7 Replies)
Discussion started by: lxdorney
7 Replies

10. UNIX for Beginners Questions & Answers

Copy the content from txt file and create a html file

I have a txt file with a list of error messages in a xml tag format, and each error message is separated with a identifier(endresult).Need to split that and copy and create a new html file.Error message has some special character. how to escape the special character and insert my data into the... (7 Replies)
Discussion started by: DevAakash
7 Replies
ALE(1)																	    ALE(1)

NAME
ale - a synthetic capture engine and renderer SYNOPSIS
ale [OPTIONS] original-frame [supplemental-frames ...] output-file ale [HELP OPTIONS] ale --version DESCRIPTION
ALE is a free software synthetic capture engine and renderer accepting, as input, a sequence of image frames, and producing, as output, rendered images, registration data, and 3D models (currently experimental). EXAMPLES
ale --hu Print the help page on program usage. ale 001.ppm 002.ppm 003.ppm out.ppm Render output file out.ppm from inputs 001.ppm, 002.ppm, and 003.ppm. ale --scale 2 001.ppm 002.ppm 003.ppm out.png Render output file out.png at 2x scale. ale --perturb-upper=0 --trans-load=a.t --projective frame*.png out.png Render output file out.png from inputs frame*.png, using projective transformations as described in the file a.t. ale --3dv 0 out.png --projective frame*.png null: Render output file out.png from inputs frame*.png, using a 3D scene model to determine transformations. ale --visp last:sinc*lanc:6 sf:0 out/ .jpg in/*.jpg null: Render a video stream from files in/*.jpg to the directory out/, stabilizing to the first frame, with a lanczos-windowed sinc filter. USAGE
ale is a wrapper script that calls the executable ale-bin after extracting exposure EXIF information from image files (when the exiftool utility is available) and converting from raw formats (when the dcraw utility is available). When ale-bin has been linked with ImageMagick, input and output files may be of any kind supported by ImageMagick. Otherwise, only PPM files can be read and written by ale-bin. OPTIONS
OPTIONS are summarized via built-in help pages (see HELP OPTIONS below). More detailed manuals describing options and internal algorithms are available for certain versions of ALE. See SEE ALSO below for more details on other manuals. HELP OPTIONS
A listing of available help options can be obtained by invoking ale --hu. ENVIRONMENT
The wrapper script ale recognizes the following environment variables: ALE_BIN ALE executable to use. DCRAW dcraw raw extraction tool to use. EXIF_UTILITY EXIF extraction utility to use. ALE_COUNT_THREADS Displays statistics on thread counts when set to a non-zero value. PAGER Text pager to use (e.g., for displaying help pages). SEE ALSO
More detailed manuals for certain versions of ALE are distributed with source packages, and may also be available from: http://auricle.dyndns.org/ALE/manuals/ 03/31/2009 ALE(1)
All times are GMT -4. The time now is 06:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy