|
| Дата |
|
USD/RUB | 93.4409 | BTC/USD | 64559.4479 |
|
|
|
Скрипты, программы и технические решения Обсуждаем скрипты, программы и новые технологии. |
11.07.2011, 23:01
|
#1
|
Senior Member
Регистрация: 17.09.2008
Сообщений: 262
Бабло: $53974
|
перевод столбца в строку
нужно сделать перевод столбцов в строку. пример
key1
key2
key3
на выходе нужно иметь
key1|key2|key3
чем можно это сделать? юзал гугл ничего дельного не нашел, имхо можно через ексель но как хз..
|
|
|
11.07.2011, 23:07
|
#2
|
рамамба хару мамбуру
Регистрация: 09.12.2008
Сообщений: 1,461
Бабло: $186145
|
в акелпаде делаю
__________________
|
|
|
11.07.2011, 23:11
|
#3
|
Where is my fucking money
Регистрация: 30.12.2008
Сообщений: 714
Бабло: $101211
|
http://www.textfixer.com/tools/remove-line-breaks.php
PHP код:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Remove Line Breaks</title>
<script>
function removeBreaks(){
var para = document.getElementById("paragraphs").checked;
var nopara = document.getElementById("noparagraphs").checked;
var noBreaksText = document.getElementById("oldText").value;
noBreaksText = noBreaksText.replace(/(\r\n|\n|\r)/gm,"<1br />");
re1 = /<1br \/><1br \/>/gi;
re1a = /<1br \/><1br \/><1br \/>/gi;
if(nopara == 1 || nopara == true){
noBreaksText = noBreaksText.replace(re1," ");
}else{
noBreaksText = noBreaksText.replace(re1a,"<1br /><2br />");
noBreaksText = noBreaksText.replace(re1,"<2br />");
}
re2 = /\<1br \/>/gi;
noBreaksText = noBreaksText.replace(re2, " | ");
re3 = /\s+/g;
noBreaksText = noBreaksText.replace(re3," ");
re4 = /<2br \/>/gi;
noBreaksText = noBreaksText.replace(re4,"\n\n");
document.getElementById("newText").value = noBreaksText;
}
</script>
</head>
<body>
<noscript class="wrn">
<p>This <strong>online text/html tool</strong> requires a javascript enabled browser to work.</p>
</noscript><form method="post" action="remove-line-breaks.php" class="online-tools">
<h2>Remove Line Breaks</h2>
<p>Paste your text in the box below and then click the button.</p>
<p>The new text will appear in the box at the bottom of the page.</p>
<p class="flat"><input type="radio" id="paragraphs" name="paragraphs" value="yes" checked="checked" /> Remove line breaks only</p>
<p class="flat"><input type="radio" id="noparagraphs" name="paragraphs" value="no" /> Remove line breaks and paragraph breaks</p>
<p><textarea id="oldText" name="oldText" rows="6" cols="36"></textarea></p>
<p><input type="button" name="Remove-Line-Breaks" value="Remove Line Breaks" onclick="javascript:removeBreaks()" class="frmbtn" /></p>
<h2>New Text without Line Breaks</h2>
<p class="flat">Copy your new text without line breaks from the box below.</p>
<p><textarea id="newText" name="newText" rows="6" cols="36" onclick="javascript:this.form.newText.focus();this.form.newText.select();"></textarea>
</p></form>
</body>
</html>
Последний раз редактировалось katardy; 11.07.2011 в 23:23.
|
|
|
12.07.2011, 00:10
|
#4
|
Je suis moine ivre
Регистрация: 03.03.2009
Сообщений: 15,268
Бабло: $797172957
|
$result=implode("|", array("key1", "key2", "key3"));
|
|
|
12.07.2011, 00:11
|
#5
|
Senior Member
Регистрация: 17.09.2008
Сообщений: 262
Бабло: $53974
ТС -->
|
ТС
спс всем.. сделал в akelpad
|
|
|
12.07.2011, 00:15
|
#6
|
Senior Member
Регистрация: 25.06.2007
Сообщений: 1,491
Бабло: $490772
|
Код:
<head>
<title>столбцевстрочкупереводилка</title>
<HTA:APPLICATION
SCROLL="yes"
SINGLEINSTANCE="no"
WINDOWSTATE="maximize"
>
</head>
<script language="VBScript">
Sub doit
titles.Value = Replace(titles.Value, vbCrLf, "|")
document.parentwindow.clipboardData.SetData "text", titles.Value
End sub
</script>
<body style="background-color:grey">
киворды<br>
<textarea name="titles" rows="20" cols="50"></textarea><br><br>
<input type="button" value="do it" onClick="doit">
</body>
сохранить как файл blabla.hta
__________________
Talitha kumi!
|
|
|
12.07.2011, 05:24
|
#7
|
Senior Member
Регистрация: 26.09.2008
Сообщений: 3,967
Бабло: $504639
|
Цитата:
Сообщение от Bljat
спс всем.. сделал в akelpad
|
Тоже делаю в текстовом редакторе такое. Выделяю перевод строки и земеняю на пробел (ну или что нужно).
|
|
|
12.07.2011, 06:44
|
#8
|
grablab.org
Регистрация: 18.09.2007
Адрес: Thailand
Сообщений: 4,893
Бабло: $322264
|
Цитата:
Сообщение от Drunk Monk
$result=implode("|", array("key1", "key2", "key3"));
|
драня программист )
|
|
|
12.07.2011, 08:44
|
#9
|
Senior Member
Регистрация: 19.09.2009
Сообщений: 4,096
Бабло: $611825
|
Цитата:
Сообщение от WebNinja
драня программист )
|
угу) тоже улыбнуло
Выложу php варивант, может кому пригодится:
PHP код:
<?
$result = implode("", file("from.txt"));
$result = str_replace("\n",'|',$result);
$fp=fopen("result.txt",'w');
fputs($fp,$result);
fclose($fp);
?>
Этот вариант для линукса, а в Виндоусе заменить \n на \r\n
|
|
|
12.07.2011, 09:15
|
#10
|
Je suis moine ivre
Регистрация: 03.03.2009
Сообщений: 15,268
Бабло: $797172957
|
Битва за дзен-код продолжается епт! Вариант для виндоуса и линукса (хавает как \n так и \r\n разделитель):
PHP код:
<? $fp=fopen("result.txt",'w'); fputs($fp, implode("|", array_map("trim", file("file.txt")))); fclose($fp); ?>
|
|
|
|