Fixing broken CSV with Windows line endings - csv

I have a CSV that looks like this:
25/04/2017,23:35:59,unknown,+123456789,Photo Message
25/04/2017,23:36:09,unknown,+123456789,Сириус конторка
25/04/2017,23:36:15,unknown,+123456789,Главный из офис
26/04/2017,08:15:55,unknown,+123456789,Напишіть будь ласка номер Житло-Капітал, за яким повідомляють:
- суму коштів до повернення/доплати
- комісію за управління інвестиційними коштами
26/04/2017,08:17:44,unknown,+123456789,374-03-08
26/04/2017,08:29:24,unknown,+123456789,Для тех, кто не был на собрании. Вчера мы:
1. Собрали контакты (фио + № квартиры + телефон) тех жильцов, которые пресутствовали на собрании.
2. Подписали заявление по счётчикам тепла.
3. Подписали заявление "щодо недоліків".
4. Коллективное обращение по договорах коммуналки.
5. Инициативная группа рассказала про текущий ход переговоров с жеком по поводу договоров.
Что дальше:
1. Ждём результатов переговоров инициативной группы с жеком. Она должна состояться сегодня.
2. Когда будут готовы согласованные с жеком договора, они будут выложены здесь и на форумах, чтобы каждый мог себе их распечатать, и сравнить с тем, что жек даст на подпись при подписании акта.
2. Кто не подписал заявления/обращения, сможет это сделать до четверга. Где их можно будет подписать - позже узнаем.
26/04/2017,08:29:53,unknown,+123456789,Колективне звернення по договорах комуналки.pdf
26/04/2017,08:29:54,unknown,+123456789,Лист щодо недоліків Забудовнику та Управителю.pdf
26/04/2017,08:29:54,unknown,+123456789,Лічильники тепла - Акцепт.pdf
It has several problems:
line endings are ^M character (see "What does ^M character mean in Vim?"),
final 5th column contains multiline lines,
final 5th column is not properly escaped, e.g. and it's the one that has bare comas sitting around.
What I know for sure that:
the CSV has 5 columns,
line ending is always ^M (e.g. it's Windows-encoded line-ending).
How can I make a proper CSV out of this one?

I think I overreacted about the complexity of this. The following code in Elixir splits the CSV file into correct list of lists:
File.read!("sample.csv")
|> String.split("\r\n")
|> Enum.map(&String.split(&1, ",", parts: 5))
Result:
[
["25/04/2017", "23:36:09", "unknown", "+123456789",
"Сириус конторка"],
["25/04/2017", "23:36:15", "unknown", "+123456789",
"Главный из офис"],
["26/04/2017", "08:15:55", "unknown", "+123456789",
"Напишіть будь ласка номер Житло-Капітал, за яким повідомляють:\n- суму коштів до повернення/доплати\n- комісію за управління інвестиційними коштами"],
["26/04/2017", "08:17:44", "unknown", "+123456789", "374-03-08"],
["26/04/2017", "08:29:24", "unknown", "+123456789",
"Для тех, кто не был на собрании. Вчера мы:\n\n1. Собрали контакты (фио + № квартиры + телефон) тех жильцов, которые пресутствовали на собрании.\n2. Подписали заявление по счётчикам тепла.\n3. Подписали заявление \"щодо недоліків\".\n4. Коллективное обращение по договорах коммуналки.\n5. Инициативная группа рассказала про текущий ход переговоров с жеком по поводу договоров.\n\nЧто дальше: \n1. Ждём результатов переговоров инициативной группы с жеком. Она должна состояться сегодня.\n2. Когда будут готовы согласованные с жеком договора, они будут выложены здесь и на форумах, чтобы каждый мог себе их распечатать, и сравнить с тем, что жек даст на подпись при подписании акта.\n2. Кто не подписал заявления/обращения, сможет это сделать до четверга. Где их можно будет подписать - позже узнаем."],
["26/04/2017", "08:29:53", "unknown", "+123456789",
"Колективне звернення по договорах комуналки.pdf"],
["26/04/2017", "08:29:54", "unknown", "+123456789",
"Лист щодо недоліків Забудовнику та Управителю.pdf"],
["26/04/2017", "08:29:54", "unknown", "+123456789",
"Лічильники тепла - Акцепт.pdf"],
[""]
]

Just in case you want a function that can remove Windows end of line:
" dos2unix ^M
if !exists('*Dos2unixFunction')
fun! Dos2unixFunction() abort
"call Preserve('%s/ $//ge')
call Preserve(":%s/\x0D$//e")
set ff=unix
set bomb
set encoding=utf-8
set fileencoding=utf-8
endfun
endif
com! Dos2Unix :call Dos2unixFunction()
cnoreabbrev dos2unix Dos2unix
cnoreabbrev d2u Dos2Unix
" This function can be called to save your cursor position
if !exists('*Preserve')
function! Preserve(command)
try
let l:win_view = winsaveview()
"silent! keepjumps keeppatterns execute a:command
silent! execute 'keeppatterns keepjumps ' . a:command
finally
call winrestview(l:win_view)
endtry
endfunction
endif

Related

How to handle newline characters in translated text?

I'm using Custom translator to translate Russian text into English. Some sentences contain \n character that means newline. And my goal is to translate the text like there are no newlines in it, but I want to preserve this \n.
Example
russian:
очередь, к которой отнесен обработчик и в которой зарегистрированы
данные, которые он будет обрабатывать.
English translation:
queue to which the handler is assigned and in which the data that it
will process is registered
This text can have \n in different places:
очередь, к которой отнесен обработчик и в которой зарегистрированы
данные, которые он будет\nобрабатывать. очередь, к которой отнесен
обработчик и в которой зарегистрированы данные\n
которые он будет
обрабатывать. очередь, к которой отнесен обработчик и в
которой\nзарегистрированы данные, которые он будет обрабатывать.
And all translations should match the first one, but preserving the '\n' position.
Is it possible? I've tried to replace \n with <BR> or with but the translation is different.
Wow! Found the solution!
Need to replace \n with <b> </b>
I could not find an elegant way of doing it. But, found a workaround. You can replace the "\n" with some word or characters from a completely different script and the translator keep it as it is, without having any effect on the translation. After you get back the translated text you can replace your dummy word with "\n".
I translated
очередь, к которой отнесен обработчик и в которой зарегистрированы
данные, которые он будет मुखपृष्ठ обрабатывать. очередь, к которой
отнесен обработчик и в которой зарегистрированы данные मुखपृष्ठ
которые он будет обрабатывать. очередь, к которой отнесен обработчик и
в которой मुखपृष्ठ зарегистрированы данные, которые он будет
обрабатывать.
and it gave me
the queue to which the handler is assigned and where the data that it
will मुखपृष्ठ process is recorded. the queue to which the handler is
assigned and in which the data मुखपृष्ठ which it will process is
recorded. the queue to which the handler is assigned and in which the
मुखपृष्ठ recorded the data that it will process.
Here I have used a "hindi" word "मुखपृष्ठ" but you can probably try with something like Japanese or something.
Just to repeat, this is just a workaround that I have found to be working at this moment, don't know if this is good enough for all kinds of use cases or if it continue to work in future.

Bootstrap 4 : Set Width of Column Width Fixed Position Content

I have a Bootstrap 4 based web page with 1 row which has 3 columns. I want the 1st and 3rd columns to have a fixed position and the 2nd column to be scrollable.
<div class="container" style="align-content:center;background-color:red;">
<div class="form-row" style=" margin: 0px;" >
<div class="col-lg-4" style="background-color:white;" >
<div style="position:fixed;">
Alapus berihal aralori nog abosiman to lere sot. Tec rihew elicip eho ma gub? Atiyi fe emanoto urigifie cep corike? Ino oraled efoponay to cinit opotare. Tadedo pet rico ocodum yetej tupe ime havi bod huwese, esofahe esereho hihuriet ner ge. Laha rig hikede ri totonic porac. Ebacep yiribos toriel delu riti iter. Cepit atobiteg tavet icut ariyase cilayon.
</div>
</div>
<div class="col-lg-6" style="background-color:red;" >
Vani vo teco laf. Eninegit uge no rayo no so sucic: Bomage rob tas? Rep sogesas mosen penude za hoyetob pin. Ilil ditolun lisafic etatem aber wah epasa pimev asic lowieso, letadol suriso la semu. Qalonur toru ha osilo herera cacal ciyod non isi? Ler cat yisegi. Ale ren geneva; lac pogeba adi nome layedir.
Vani vo teco laf. Eninegit uge no rayo no so sucic: Bomage rob tas? Rep sogesas mosen penude za hoyetob pin. Ilil ditolun lisafic etatem aber wah epasa pimev asic lowieso, letadol suriso la semu. Qalonur toru ha osilo herera cacal ciyod non isi? Ler cat yisegi. Ale ren geneva; lac pogeba adi nome layedir.
Vani vo teco laf. Eninegit uge no rayo no so sucic: Bomage rob tas? Rep sogesas mosen penude za hoyetob pin. Ilil ditolun lisafic etatem aber wah epasa pimev asic lowieso, letadol suriso la semu. Qalonur toru ha osilo herera cacal ciyod non isi? Ler cat yisegi. Ale ren geneva; lac pogeba adi nome layedir.
Vani vo teco laf. Eninegit uge no rayo no so sucic: Bomage rob tas? Rep sogesas mosen penude za hoyetob pin. Ilil ditolun lisafic etatem aber wah epasa pimev asic lowieso, letadol suriso la semu. Qalonur toru ha osilo herera cacal ciyod non isi? Ler cat yisegi. Ale ren geneva; lac pogeba adi nome layedir.
Vani vo teco laf. Eninegit uge no rayo no so sucic: Bomage rob tas? Rep sogesas mosen penude za hoyetob pin. Ilil ditolun lisafic etatem aber wah epasa pimev asic lowieso, letadol suriso la semu. Qalonur toru ha osilo herera cacal ciyod non isi? Ler cat yisegi. Ale ren geneva; lac pogeba adi nome layedir.
</div>
<div class="col-lg-2" style="background-color:yellow;" >
<div style="position:fixed;">
Cegeh na rasi nitora sep lim ded so rar? Po tosula iwe ciyirif; iro seri la nenegac ralala meralak, nomir na lerorer! Lita resonop eropem enulose mi rer ne tacacal yumo calos. Dic teril satec yel wupip rar: Keye hipoce egol ecimi ra cienet. Yohicem niran sor naqetar odecafel eso ronu tunerig sos: Musedu roy tegovi hu reru inaca. Lo onobeda ategat de. Ikikosen polie re uweme ronepo. Mitif reqepu sel. Fubiel pac madotil pip, nedupa rotolin re deciso riciho; tenabir rakira nay asaluti yer reci penede iepaso.
</div>
</div>
</div>
</div>
The content of the 3rd column exceeds the column. If I remove position:fixed, the content stays within the column, but the column becomes scrollable. If I use position:sticky, I don't know what to set the top attribute to without using javascript. Does anyone know how I can keep the content of the column fixed while keeping it within the column?
You just have to do something like this :
<div class="col-md-3 h-100">...</div>
<div class="col-md-3 h-100 scrolling-content">...</div>
<div class="col-md-3 h-100">...</div>
And in you css :
.scrolling-content {
overflow: scroll;
}
You can use this code
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>Demo</title>
<style type="text/css">
body {
margin: 0;
}
.box {
overflow: scroll;
}
</style>
</head>
<body>
<div class="container" style="align-content: center; background-color: red;">
<div class="form-row row" style=" margin: 0px;">
<div class="col-md-4" style="background-color: white;">
Alapus berihal aralori nog abosiman to lere sot. Tec rihew elicip eho ma gub? Atiyi fe emanoto urigifie cep corike? Ino oraled efoponay to cinit opotare. Tadedo pet rico ocodum yetej tupe ime havi bod huwese, esofahe esereho hihuriet ner ge. Laha rig
hikede ri totonic porac. Ebacep yiribos toriel delu riti iter. Cepit atobiteg tavet icut ariyase cilayon.
</div>
<div class="col-md-6 box" style="background-color: red;">
Vani vo teco laf. Eninegit uge no rayo no so sucic: Bomage rob tas? Rep sogesas mosen penude za hoyetob pin. Ilil ditolun lisafic etatem aber wah epasa pimev asic lowieso, letadol suriso la semu. Qalonur toru ha osilo herera cacal ciyod non isi? Ler cat
yisegi. Ale ren geneva; lac pogeba adi nome layedir. Vani vo teco laf. Eninegit uge no rayo no so sucic: Bomage rob tas? Rep sogesas mosen penude za hoyetob pin. Ilil ditolun lisafic etatem aber wah epasa pimev asic lowieso, letadol suriso la
semu. Qalonur toru ha osilo herera cacal ciyod non isi? Ler cat yisegi. Ale ren geneva; lac pogeba adi nome layedir. Vani vo teco laf. Eninegit uge no rayo no so sucic: Bomage rob tas? Rep sogesas mosen penude za hoyetob pin. Ilil ditolun lisafic
etatem aber wah epasa pimev asic lowieso, letadol suriso la semu. Qalonur toru ha osilo herera cacal ciyod non isi? Ler cat yisegi. Ale ren geneva; lac pogeba adi nome layedir. Vani vo teco laf. Eninegit uge no rayo no so sucic: Bomage rob tas?
Rep sogesas mosen penude za hoyetob pin. Ilil ditolun lisafic etatem aber wah epasa pimev asic lowieso, letadol suriso la semu. Qalonur toru ha osilo herera cacal ciyod non isi? Ler cat yisegi. Ale ren geneva; lac pogeba adi nome layedir. Vani
vo teco laf. Eninegit uge no rayo no so sucic: Bomage rob tas? Rep sogesas mosen penude za hoyetob pin. Ilil ditolun lisafic etatem aber wah epasa pimev asic lowieso, letadol suriso la semu. Qalonur toru ha osilo herera cacal ciyod non isi? Ler
cat yisegi. Ale ren geneva; lac pogeba adi nome layedir.
</div>
<div class="col-md-2" style="background-color: yellow;">
Cegeh na rasi nitora sep lim ded so rar? Po tosula iwe ciyirif; iro seri la nenegac ralala meralak, nomir na lerorer! Lita resonop eropem enulose mi rer ne tacacal yumo calos. Dic teril satec yel wupip rar: Keye hipoce egol ecimi ra cienet. Yohicem niran
sor naqetar odecafel eso ronu tunerig sos: Musedu roy tegovi hu reru inaca. Lo onobeda ategat de. Ikikosen polie re uweme ronepo. Mitif reqepu sel. Fubiel pac madotil pip, nedupa rotolin re deciso riciho; tenabir rakira nay asaluti yer reci penede
iepaso.
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>

Extracting text from HTML page in R

I am working on drugbank database, please i need help to extract specific text from the below HTML code:
<table>
<tr>
<td>Text</td>
</tr>
<tr>
<th>ATC Codes</th>
<td>B01AC05
<ul class="atc-drug-tree">
<li><a data-no-turbolink="true" href="/atc/B01AC">B01AC — Platelet aggregation inhibitors excl. heparin</a></li>
<li><a data-no-turbolink="true" href="/atc/B01A">B01A — ANTITHROMBOTIC AGENTS</a></li>
<li><a data-no-turbolink="true" href="/atc/B01">B01 — ANTITHROMBOTIC AGENTS</a></li>
<li><a data-no-turbolink="true" href="/atc/B">B — BLOOD AND BLOOD FORMING ORGANS</a></li>
</ul>
</td>
</tr>
<tr>
<td>Text</td>
</tr>
</table>
i want to have the following as my output text as list object:
B01AC05
B01AC — Platelet aggregation inhibitors excl. heparin
B01A — ANTITHROMBOTIC AGENTS
B01 — ANTITHROMBOTIC AGENTS
B — BLOOD AND BLOOD FORMING ORGANS
I have tried the below function but its not working:
library(XML)
getATC <- function(id){
url <- "http://www.drugbank.ca/drugs/"
dburl <- paste(url, id, sep ="")
tables <- readHTMLTable(dburl, header = F)
table <- tables[['atc-drug-tree']]
table
}
ids <- c("DB00208", "DB00209")
ref <- apply(ids, 1, getATC)
NB:
The url can be use to see the actual page i want to parse, the HTML snippet i provided was just and example.
Thanks
rvest makes web scraping pretty simple. Here's a solution using it.
library("rvest")
library("stringr")
your_html <- read_html('<table>
<tr>
<td>Text</td>
</tr>
<tr>
<th>ATC Codes</th>
<td>B01AC05
<ul class="atc-drug-tree">
<li><a data-no-turbolink="true" href="/atc/B01AC">B01AC — Platelet aggregation inhibitors excl. heparin</a></li>
<li><a data-no-turbolink="true" href="/atc/B01A">B01A — ANTITHROMBOTIC AGENTS</a></li>
<li><a data-no-turbolink="true" href="/atc/B01">B01 — ANTITHROMBOTIC AGENTS</a></li>
<li><a data-no-turbolink="true" href="/atc/B">B — BLOOD AND BLOOD FORMING ORGANS</a></li>
</ul>
</td>
</tr>
<tr>
<td>Text</td>
</tr>
</table>')
your_name <-
your_html %>%
html_nodes(xpath='//th[contains(text(), "ATC Codes")]/following-sibling::td') %>%
html_text() %>%
str_extract(".+(?=\n)")
list_elements <-
your_html %>% html_nodes("li") %>% html_nodes("a") %>% html_text()
your_list <- list()
your_list[[your_name]] <- list_elements
> your_list
$B01AC05
[1] "B01AC — Platelet aggregation inhibitors excl. heparin"
[2] "B01A — ANTITHROMBOTIC AGENTS"
[3] "B01 — ANTITHROMBOTIC AGENTS"
[4] "B — BLOOD AND BLOOD FORMING ORGANS"
Create the URL strings and sapply them using the getDrugs function which parses the HTML, extracts the root of the HTML tree, finds the ul node with the indicated class and returns its parent's text (but only before the first whitespace) followed by the text in each ./li/a grandchild:
library(XML)
getDrugs <- function(...) {
doc <- htmlTreeParse(..., useInternalNodes = TRUE)
xpathApply(xmlRoot(doc), "//ul[#class='atc-drug-tree']", function(node) {
c(sub("\\s.*", "", xmlValue(xmlParent(node))), # get text before 1st whitespace
xpathSApply(node, "./li/a", xmlValue)) # get text in each ./li/a node
})
}
ids <- c("DB00208", "DB00209")
urls <- paste0("http://www.drugbank.ca/drugs/", ids)
L <- sapply(urls, getDrugs)
giving the following list (one component per URL and a component within each for each drug found in that URL):
> L
$`http://www.drugbank.ca/drugs/DB00208`
$`http://www.drugbank.ca/drugs/DB00208`[[1]]
[1] "B01AC05B01AC"
[2] "B01AC — Platelet aggregation inhibitors excl. heparin"
[3] "B01A — ANTITHROMBOTIC AGENTS"
[4] "B01 — ANTITHROMBOTIC AGENTS"
[5] "B — BLOOD AND BLOOD FORMING ORGANS"
$`http://www.drugbank.ca/drugs/DB00209`
$`http://www.drugbank.ca/drugs/DB00209`[[1]]
[1] "A03DA06A03DA"
[2] "A03DA — Synthetic anticholinergic agents in combination with analgesics"
[3] "A03D — ANTISPASMODICS IN COMBINATION WITH ANALGESICS"
[4] "A03 — DRUGS FOR FUNCTIONAL GASTROINTESTINAL DISORDERS"
[5] "A — ALIMENTARY TRACT AND METABOLISM"
$`http://www.drugbank.ca/drugs/DB00209`[[2]]
[1] "A03DA06A03DA"
[2] "G04BD — Drugs for urinary frequency and incontinence"
[3] "G04B — UROLOGICALS"
[4] "G04 — UROLOGICALS"
[5] "G — GENITO URINARY SYSTEM AND SEX HORMONES"
We could create a 5x3 matrix out of the above like this:
simplify2array(do.call(c, L))
And here is a test using the input in the question:
Lines <- '<table>
<tr>
<td>Text</td>
</tr>
<tr>
<th>ATC Codes</th>
<td>B01AC05
<ul class="atc-drug-tree">
<li><a data-no-turbolink="true" href="/atc/B01AC">B01AC — Platelet aggregation inhibitors excl. heparin</a></li>
<li><a data-no-turbolink="true" href="/atc/B01A">B01A — ANTITHROMBOTIC AGENTS</a></li>
<li><a data-no-turbolink="true" href="/atc/B01">B01 — ANTITHROMBOTIC AGENTS</a></li>
<li><a data-no-turbolink="true" href="/atc/B">B — BLOOD AND BLOOD FORMING ORGANS</a></li>
</ul>
</td>
</tr>
<tr>
<td>Text</td>
</tr>
</table>'
getDrugs(Lines, asText = TRUE)
giving:
[[1]]
[1] "B01AC05"
[2] "B01AC — Platelet aggregation inhibitors excl. heparin"
[3] "B01A — ANTITHROMBOTIC AGENTS"
[4] "B01 — ANTITHROMBOTIC AGENTS"
[5] "B — BLOOD AND BLOOD FORMING ORGANS"
readHTMLTable is not working because it can't read the headers in tables 3 and 4.
url <- "http://www.drugbank.ca/drugs/DB00208"
doc <- htmlParse(readLines(url))
summary(doc)
$nameCounts
td a tr li th span div p strong img table ...
745 399 342 175 159 137 66 49 46 27 27
#errors
readHTMLTable(doc)
readHTMLTable(doc, which=3)
# this works
readHTMLTable(doc, which=3, header=FALSE)
Also, ATC codes is not within a nearby table tag, so you have to use xpath like the other answers here.
xpathSApply(doc, '//ul[#class="atc-drug-tree"]/*', xmlValue)
[1] "B01AC — Platelet aggregation inhibitors excl. heparin" "B01A — ANTITHROMBOTIC AGENTS"
[3] "B01 — ANTITHROMBOTIC AGENTS" "B — BLOOD AND BLOOD FORMING ORGANS"
xpathSApply(doc, '//ul[#class="atc-drug-tree"]/../node()[1]', xmlValue)
[1] "B01AC05"

Dust helper equal for select control

I have this template i need select proper selected option, how to compare it with dust helpers? https://stackoverflow.com/a/19628029/880709 didn't work for me
{#data.PRODUCT_TURNOVER_DATA}
<tr>
<td><input name="ID_TYPE_TURN" value='{.ID_TYPE_TURN}'></td>
<td>
<div class="form-group">
<select class="form-control" name="ID_TYPE_TURN">
{#data.SPR_TYPE_TURN_DATA}
<option value="{.ID_TYPE_TURN}" selected='?'>{.NAME_TYPE_TURN}</option>
{/data.SPR_TYPE_TURN_DATA}
</select>
</div>
</td>
</tr>
{/data.PRODUCT_TURNOVER_DATA}
Data:
"data": {
"PRODUCT_TURNOVER_DATA": [
{
"ID_PRODUCT_TURNOVER": 4,
"DATE_TURN": "2015-12-29T21:00:00.000Z",
"ID_TYPE_TURN": 2,
}
],
"SPR_TYPE_TURN_DATA": [
{
"ID_TYPE_TURN": 1,
"NAME_TYPE_TURN": "Передано в составе УТАС",
"ACC_OPT": 1
},
{
"ID_TYPE_TURN": 2,
"NAME_TYPE_TURN": "Получено от контрагента для ревизии",
"ACC_OPT": -1
}]
Criteria of equality
PRODUCT_TURNOVER_DATA.ID_TYPE_TURN == SPR_TYPE_TURN_DATA.ID_TYPE_TURN
You can use the {#eq} helper to compare these two values.
<option value="{.ID_TYPE_TURN}" {#eq key=PRODUCT_TURNOVER_DATA[0].ID_TYPE_TURN value=.ID_TYPE_TURN}selected='selected'{/eq}>{.NAME_TYPE_TURN}</option>

Issue with aspose.cell ”.HtmlString” property ,When html tag text contain character “&”

HTML
<Font Style='FONT-FAMILY: Arial;FONT-SIZE: 9pt;COLOR: #000000;TEXT-ALIGN: left;FONT-WEIGHT: bold;'>Status: </Font>
<Font Style='FONT-FAMILY: Arial;FONT-SIZE: 9pt;COLOR: #000000;TEXT-ALIGN: left;'>REGISTERED 8 **&** 15, June 20, 2003</Font>
<Font Style='FONT-FAMILY: Arial;FONT-SIZE: 9pt;COLOR: #000000;TEXT-ALIGN: left;FONT-WEIGHT: bold;'>Int'l Class: </Font>
<Font Style='FONT-FAMILY: Arial;FONT-SIZE: 9pt;COLOR: #000000;TEXT-ALIGN: left;'> 25</Font>
Processed HTML by aspose property .HtmlString
**worksheet.Cells[rowTiled, columnTiled].HtmlString = __htmlString;**
<Font Style="FONT-WEIGHT: bold;FONT-FAMILY: Arial;FONT-SIZE: 9pt;COLOR: #000000;">Status: </Font>
<Font Style="FONT-FAMILY: Arial;FONT-SIZE: 9pt;COLOR: #000000;">REGISTERED 8 **&** 15, June 20, 2003</Font>
<Font Style='FONT-FAMILY: Arial;FONT-SIZE: 9pt;COLOR: #000000;TEXT-ALIGN: left;FONT-WEIGHT: bold;'>Int'l Class: </Font>
<Font Style="FONT-FAMILY: Arial;FONT-SIZE: 9pt;COLOR: #000000;"> 25</Font>
Issue with aspose .HtmlString property process character & to & but it also convert some html tag < and> in encoded format.
This formation create wrong string, that’s why I got HTML text in my Excel Sheet.
I am working as Social Media Developer at Aspose.
Well, you need to use "&amp ;" instead of "&" in your html string to use it with Aspose.Cells for .NET. I checked the following code with latest version and it works fine.
//instantiate workbook
Workbook wb = new Workbook();
//Get worksheet
Worksheet ws = wb.Worksheets[0];
//Get Cells
Aspose.Cells.Cells cell = ws.Cells;
//Set HTML String
cell[0, 0].HtmlString = "<Font Style='FONT-FAMILY: Arial;FONT-SIZE: 9pt;COLOR: #000000;TEXT-ALIGN: left;FONT-WEIGHT: bold;'>Status: </Font><Font Style='FONT-FAMILY: Arial;FONT-SIZE: 9pt;COLOR: #000000;TEXT-ALIGN: left;'>REGISTERED 8 & 15, June 20, 2003</Font><Font Style='FONT-FAMILY: Arial;FONT-SIZE: 9pt;COLOR: #000000;TEXT-ALIGN: left;FONT-WEIGHT: bold;'>Int'l Class: </Font><Font Style='FONT-FAMILY: Arial;FONT-SIZE: 9pt;COLOR: #000000;TEXT-ALIGN: left;'> 25</Font>";
//Save Workbook
wb.Save("c:\\data\\outputhtmlstring.xlsx");