Search Results

Search found 4783 results on 192 pages for 'txt'.

Page 31/192 | < Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >

  • Function for putting all database table to an array

    - by jasmine
    I have written a function to print database table to an array like this $db_array= Array( ID=>1, PARENTID =>1, TITLE => LIPSUM, TEXT =>LIPSUM ) My function is: function dbToArray($table) { $allArrays =array(); $query = mysql_query("SELECT * FROM $table"); $dbRow = mysql_fetch_array($query); for ($i=0; $i<count($dbRow) ; $i++) { $allArrays[$i] = $dbRow; } $txt .='<pre>'; $txt .= print_r($allArrays); $txt .= '</pre>'; return $txt; } Anything wrong in my function. Any help is appreciated about my problem. Thanks in advance

    Read the article

  • how to fetch exact string from a text file

    - by user136104
    Hi All, here is me requirement. I have one text file and I need to get exact specified string from that file C:>type small.txt | find "small2" small2 small22 small20 C:>type small.txt small2 small22 small20 C:>type small.txt | find "small2" small2 small22 small20 C:\ Here it is giving all the words instead of only "small2" Plz help me in this.. it's urgent Thanks in advance

    Read the article

  • javascript to select text from web page

    - by phil swenson
    I'm trying to write a bookmarklet that grabs any selected text on a web page and sends it to my website. It should (hopefully) work in Chrome, FFX, Safari, and IE. I did a search and found a function, but it doesn't appear to work. Here is the code: <html> <body> <div onClick=getSelText()>Click</div> <div>please select me</div> </body> <script language=javascript> function getSelText(){ var txt = 'nothing'; if (window.getSelection){ txt = "1" + window.getSelection(); } else if (document.getSelection) { txt = "2" + document.getSelection(); } else if (document.selection) { txt = "3" + document.selection.createRange().text; } else return; alert("selected text = " + txt); } </script> </html> when I select the text in the div "please select me" and hit the click div, I just get "selected text = 1" thanks

    Read the article

  • search for a string , and add if it matches

    - by Sharat Chandra
    I have a file that has 2 columns as given below.... 101 6 102 23 103 45 109 36 101 42 108 21 102 24 109 67 and so on...... I want to write a script that adds the values from 2nd column if their corresponding first column matches for example add all 2nd column values if it's 1st column is 101 add all 2nd column values if it's 1st colummn is 102 add all 2nd column values if it's 1st colummn is 103 and so on ... i wrote my script like this , but i'm not getting the correct result awk '{print $1}' data.txt > col1.txt while read line do awk ' if [$1 == $line] sum+=$2; END {print "Sum for time stamp", $line"=", sum}; sum=0' data.txt done < col1.txt

    Read the article

  • Moving and renaming files, keeping extension but include sub directories in batch file

    - by Ser1esII
    Forgive me if this is nor the place to ask these questions, I am new to batch and scripts and a bit new to these kind of posts... I have a folder that will receive files and folders, I want to run a script that looks at the directory and renames all files in each subfolder numerically, and moves them if possible. For example I have something that looks like the following Recieved_File_Folder |_folder1 | |_file1.txt | |_file2.bmp |_folder2 | |_file4.exe | |_file5.bmp |__file9.txt |__file10.jpg I would like to be able to look in every directory and move it to something like this, keeping in mind the names of the files will be random and I want to keep the extension intact also. Renamed_Folder |_folder1 | |_1.txt | |_2.bmp |_folder2 | |_1.exe | |_2.bmp |__1.txt |__2.jpg I have spent alot of time on this and am not doing too well with it, any help would be very greatly appreciated!! Thank you in advance!

    Read the article

  • Merge two text files at a specific location, sed or awk.

    - by S1syphus
    I have two text files, I want to place a text in the middle of another, I did some research and found information about adding single strings: I have a comment in the second text file called STUFFGOESHERE, so I tried: sed '/^STUFFGOESHERE/a file1.txt' file2.txt sed: 1: "/^STUFFGOESHERE/a long.txt": command a expects \ followed by text So I tried something different, trying to place the contents of the text based on a given line, but no luck. Any ideas?

    Read the article

  • Output only characters between [ABC] and [/ABC]

    - by user564530
    $ cat somefile.txt afsdfv asdf[ABC]dafga asdfasf yxcvyxv[/ABC] asdadf yv[ABC]sdfb sdfgadfg [/ABC]adf asdf $ cat somefile.txt | NEEDEDONELINER > output.txt dafga asdfasf yxcvyxv sdfb sdfgadfg $ So the "NEEDEDONELINER" only outputs the characters between a [ABC] and [/ABC]. [ABC] could occur several times, and there could be random characters around it. I only need the random chars between the [ABC] and [/ABC]. I don't have time to learn Perl :\ Thank you in anticipiation!

    Read the article

  • Ruby string encoding problem

    - by John Prideaux
    I've looked at the other ruby/encoding related posts but haven't been able to figure out why the following is not working. Likely just because I'm dense, but here's the situation. Using Ruby 1.9 on windows. I have a set of CSV files that need some data appended to the end of each line. Whenever I run my script, the appended characters are gibberish. The input text appears to be IBM437 encoding, whereas my string I'm appending starts as US-ASCII. Nothing I've tried with respect to forcing encoding on the input strings or the append string seems to change the resultant output. I'm stumped. The current encoding version is simply the last that I tried. def append_salesperson(txt, salesperson) if txt.length > 2 return txt.chomp.force_encoding('US-ASCII') + %(, "", "", "#{salesperson}") end end salespeople = Hash[ "fname", "Record Manager"] outfile = File.open("ActData.csv", "w:US-ASCII") salespeople.each do | filename, recordManager | infile = File.open("#{filename}.txt") infile.each do |line| outfile.puts append_salesperson(line, recordManager) end infile.close end outfile.close

    Read the article

  • Insert text depending on time of day and day of week.

    - by ploughansen
    I'm trying to piece together a php script to output different text depending on what day it is and the time of day. Example: On weekdays (mon-fri), I would like to output text according to the following periods of time (24H, server time, UTC): 00:00-08:00: "Lorem ipsum" 08:00-13:00: "dolor sit amet" 13:00-15:00: "Pellentesque habitant" 15:00-15:30: "dolor sit amet" 15:30-24:00: "Lorem ipsum" On weekends (sat-sun), I would like to output the following text in this time period: 00:00-24:00 "Lorem ipsum" Can anyone help with a php script to do that? I've already gotten some help over at the css-tricks forum. They supplied this code: <?php $date = strtotime("now"); $hour = date("H", $date); switch($hour) { case 00: case 01: case 02: case 03: case 04: case 05: case 06: case 07: case 08: $dets = array("img" => "image1.png", "txt" => "Lorem ipsum"); break; case 09: case 10: case 11: case 12: case 13: $dets = array("img" => "image2.png", "txt" => "dolor sit amet"); break; case 14: case 15: case 16: $dets = array("img" => "image3.png", "txt" => "Pellentesque habitant"); break; case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: $dets = array("img" => "image1.png", "txt" => "Lorem ipsum"); break; } echo "<img src='$dets[img]' alt='$dets[txt]' />"; ?> But it works for all days, and only in full hours. I want to be able to specify per half-hour and on a day to day basis. Still a php-noob so I'm hoping someone can help me.

    Read the article

  • Capture node.js crash reason

    - by dfilkovi
    I have a script written in node.js, it uses 'net' library and communicates with distant service over tcp. This script is started using 'node script.js log.txt' command and everything in that script that is logged using console.log() function gets written to log.txt but sometimes script dies and I cannot find a reason and nothing gets logged in log.txt around the time script crashed. How can I capture crash reason?

    Read the article

  • How to Implement Web Based Find File Database Text Search

    - by neversaint
    I have series of files like this: foo1.txt.gz foo2.txt.gz bar1.txt.gz ..etc.. and a tabular format files that describe the file foo1 - Explain foo1 foo2 - Explain foo2 bar1 - Explain bar1 ..etc.. What I want to do is to have a website with a simple search bar and allow people to type foo1 or just foo and finally return the gzipped file(s) and the explanation of the file(s). What's the best way to implement this. Sorry I am totally new in this area.

    Read the article

  • Use matching value of a RegExp to name the output file.

    - by fx42
    I have this file "file.txt" which I want to split into many smaller ones. Each line of the file has an id field which looks like "id:1" for a line belonging to id 1. For each id in the file, I like to create a file named idid.txt and put all lines that belong to this id in that file. My brute force bash script solution reads as follows. count=1 while [ $count -lt 19945 ] do cat file.txt | grep "id:$count " >> ./sets/id$count.txt count='expr $count + 1' done Now this is very inefficient as I have do read through the file about 20.000 times. Is there a way to do the same operation with only one pass through the file? - What I'm probably asking for is a way to use the value that matches for a regular expression to name the associated output file.

    Read the article

  • How do I define nmake macro from command line output?

    - by Mike Atlas
    I'd like to capture the output from a tool from the command line into an nmake macro. If this were a normal command line script, it would look like this: > MyTool.exe > output.txt > set /P MyVariable=<output.txt > echo %MyVariable% However, I can't seem to find anything relevant in the nmake doc on macros that is relevant. This is basically what I'd like to do, though: target: @call MyTool.exe > output.txt # This doesn't work in .mak, unfortunately. Help! @MyVariable=<output.txt

    Read the article

  • On Solaris, what is the difference between cut and gcut?

    - by Chris J
    I recently came across this crazy script bug on one of my Solaris machines. I found that cut on Solaris skips lines from the files that it processes (or at least very large ones - 800 MB in my case). > cut -f 1 test.tsv | wc -l 457030 > gcut -f 1 test.tsv | wc -l 840571 > cut -f 1 test.tsv > temp_cut_1.txt > gcut -f 1 test.tsv > temp_gcut_1.txt > diff temp_cut_1.txt temp_gcut_1.txt | grep '[<]' | wc -l 0 My question is what the hell is going on with Solaris cut? My solution is updating my scripts to use gcut but... what the hell?

    Read the article

  • wxPython ,Change the background colour of a StyledTextCtrl

    - by user1357159
    I tried (but nothing happens) self.txt.SetBackgroundColour ((255,0,0)) As said in the title I'm trying to change the background colour StyledTextCtrl. Does anyone know a method that could be used? I've checked the API docs but I couldn't seem to find one, http://wxpython.org/docs/api/wx.stc.StyledTextCtrl-class.html (by background colour, I mean the whole writing area, of course) Does anyone know a way I could do this? EDIT: The background doesn't change in the following code import wx import wx.stc app = wx.App(redirect=True) top = wx.Frame(None, title="StyledTXTCtrl", size=(300,200)) txt=wx.stc.StyledTextCtrl(top) txt.SetBackgroundColour((255,255,0)) txt.Refresh() top.Show() app.MainLoop()

    Read the article

  • close file with fopen() but file still in use

    - by Marco
    Hi all, I've got a problem with deleting/overwriting a file using my program which is also being used(read) by my program. The problem seems to be that because of the fact my program is reading data from the file (output.txt) it puts the file in a 'in use' state which makes it impossible to delete or overwrite the file. I don't understand why the file stays 'in use' because I close the file after use with fclose(); this is my code: bool bBool = true while(bBool){ //Run myprogram.exe tot generate (a new) output.txt //Create file pointer and open file FILE* pInputFile = NULL; pInputFile = fopen("output.txt", "r"); // //then I do some reading using fscanf() // //And when I'm done reading I close the file using fclose() fclose(pInputFile); //The next step is deleting the output.txt if( remove( "output.txt" ) == -1 ){ //ERROR }else{ //Succesfull } } I use fclose() to close the file but the file remains in use by my program until my program is totally shut down. What is the solution to free the file so it can be deleted/overwrited? In reality my code isn't a loop without an end ; ) Thanks in advance! Marco

    Read the article

  • multiline sed using backreferences...

    - by pagid
    Hi, I'm converting patch scripts using a commandline script - within these scripts there's the combination two lines like: --- /dev/null +++ filename.txt which needs to be converted to: --- filename.txt +++ filename.txt Initially I tried: less file.diff | sed -e "s/---\/dev\null\n+++ \(.*\)/--- \1\n+++ \1/" But I had to find out that multiline-handling is much more complex in sed :( Any help is appreciated...

    Read the article

  • Call PHP Function in jQuery (var)

    - by l3gion
    Hello, I'm facing a small problem that I can't solve by myself. I have this php function: function intervalo_manha(){ $que="select id_intervalo,data_15 from intervalo_manha order by id_intervalo"; $re=mysql_query($que); $object.="<select>"; $object.="<option></option>"; while(list($id_intervalo, $data_15)=mysql_fetch_row($re)) { $object.= "<option value=\"".$id_intervalo."\">".$data_15."</option>"; } $object.="</select>"; return $object; } This function return a select with information from database. I also have this js function: $(document).ready(function() { var destTable = $("#dataTable"); $("#btnAdd").click(function() { var newRow = $("<tr style='margin-left:-60px'><td><INPUT type='checkbox' name='chk'/></td><td><INPUT type='text' name='txt[]' id='txt'/></td><td></td></tr>"); $("#dataTable").append(newRow); newRow.find('input').autocomplete("get_cols_name.php", { width: 260, matchContains: true, selectFirst: false }); }); }); This one will add a new row to my table, and for each new input will "activate" autocomplete. What I want to do is, instead of this: var newRow = $("<tr style='margin-left:-60px'><td><INPUT type='checkbox' name='chk'/></td><td><INPUT type='text' name='txt[]' id='txt'/></td><td></td></tr>"); I would like to have something like this: var newRow = $("<tr style='margin-left:-60px'><td><INPUT type='checkbox' name='chk'/></td><td><INPUT type='text' name='txt[]' id='txt'/></td><td><?php echo intervalo_manha(); ?></td></tr>"); Calling php function directly will return nothing, and I can't do anything. Is there any way to accomplish this? Thank you

    Read the article

  • Sed non greedy curly braces match

    - by Cesar
    I have a string in a file a.txt {moslate}alho{/moslate}otra{moslate}a{/moslate} a need to get the string otra using sed. With this regex sed 's|{moslate}.*{/moslate}||g' a.txt a get no output at all but when i add a ? to the regex s|{moslate}.*?{/moslate}||g a.txt (I've read somewhere that it makes the regex non-greedy) i get no match at all, i mean a get the following output {moslate}alho{/moslate}otra{moslate}a{/moslate} How can i get the required output using sed?

    Read the article

  • Adding file names to an array list in java

    - by Chris G
    Hi I am currently needing to load the contents of a folders filenames to an arraylist I have but I am unsure as how to do this. To put it into perspective I have a folder with One.txt, Two.txt, Three.txt etc. I want to be able to load this list into an arraylist so that if I was to check the arraylist its contents would be : arraylist[0] = One arraylist[1] = Two arraylist[3] = Three If anyone could give me any insight into this it would be much appreciated.

    Read the article

  • Powershell: Writing errors and ouput to a text file and Console

    - by smaclell
    I am trying to write the entire output (errors included) of an executing script to the console and a file at the same time. I have tried several different options .\MyScript.ps1 | tee -filePath C:\results.txt # only the output to the file .\MyScript.ps1 2> C:\results.txt # only the errors to the file and not the console .\MyScript.ps1 > C:\results.txt # only the output to the file and not the console My hope was that I could use the file to review the output/errors Any help would be greatly appreciated.

    Read the article

  • Why cant Git merge file changes with a modified parent/master.

    - by Andy
    I have a file with one line in it. I create a branch and add a second line to the same file. Save and commit to the branch. I switch back to the master. And add a different, second line to the file. Save and commit to the master. So there's now 3 unique lines in total. If I now try and merge the branch back to the master, it suffers a merge conflict. Why cant Git simple merge each line, one after the other? My attempt at merge behaves something like this: PS D:\dev\testing\test1> git merge newbranch Auto-merging hello.txt CONFLICT (content): Merge conflict in hello.txt Automatic merge failed; fix conflicts and then commit the result. PS D:\dev\testing\test1> git diff diff --cc hello.txt index 726eeaf,e48d31a..0000000 --- a/hello.txt +++ b/hello.txt @@@ -1,2 -1,2 +1,6 @@@ This is the first line. - New line added by master. -Added a line in newbranch. ++<<<<<<< HEAD ++New line added by master. ++======= ++Added a line in newbranch. ++>>>>>>> newbranch Is there a way to make it slot lines in automatically, one after the other?

    Read the article

  • Majority Voting in perl?

    - by aliocee
    Hi, i have 5 files containing the same words, i want read each word in all files and decide the winning word by detecting the following characters in a word (*, #, $, &) and generate output file i can only have 2 winners for example: file1 we$ are* ... file2 we$ are* ... file3 we* are$ ... file4 we$ are$ ... file5 we# are& ... output file: we$ - we$ is the winner since it occur in 3 files. are*$ - are* and are$ are the winners since both occur 2 times. here is how i started: #!/usr/local/bin/perl -w sub read_file_line { my $fh = shift; if ($fh and my $line = <$fh>) { chomp($line); return $line; } return; } open(my $f1, "words1.txt") or die "Can't"; open(my $f2, "words2.txt") or die "Can't"; open(my $f3, "words3.txt") or die "Can't"; open(my $f4, "words4.txt") or die "Can't"; open(my $f5, "words5.txt") or die "Can't"; my $r1 = read_file_line($f1); my $r2 = read_file_line($f2); my $r3 = read_file_line($f3); my $r4 = read_file_line($f4); my $r5 = read_file_line($f5); while ($f5) { what can i do here to decide and write the winning word in the output file? $r1 = read_file_line($f1); $r2 = read_file_line($f2); $r3 = read_file_line($f3); $r4 = read_file_line($f4); $r5 = read_file_line($f5); } Thanks.

    Read the article

  • Stop writing blank line at the end of CSV file (using MATLAB)

    - by Grant M.
    Hello all ... I'm using MATLAB to open a batch of CSV files containing column headers and data (using the 'importdata' function), then I manipulate the data a bit and write the headers and data to new CSV files using the 'dlmwrite' function. I'm using the '-append' and 'newline' attributes of 'dlmwrite' to add each line of text/data on a new line. Each of my new CSV files has a blank line at the end, whereas this blank line was not there before when I read in the data ... and I'm not using 'newline' on my final call of 'dlmwrite'. Does anyone know how I can keep from writing this blank line to the end of my CSV files? Thanks for your help, Grant EDITED 5/18/10 1:35PM CST - Added information about code and text file per request ... you'll notice after performing the procedure below that there appears to be a carriage return at the end of the last line in the new text file. Consider a text file named 'textfile.txt' that looks like this: Column1, Column2, Column3, Column4, Column 5 1, 2, 3, 4, 5 1, 2, 3, 4, 5 1, 2, 3, 4, 5 1, 2, 3, 4, 5 1, 2, 3, 4, 5 Here's a sample of the code I am using: % import data importedData = importdata('textfile.txt'); % manipulate data importedData.data(:,1) = 100; % store column headers into single comma-delimited % character array (for easy writing later) columnHeaders = importedData.textdata{1}; for counter = 2:size(importedData.textdata,2) columnHeaders = horzcat(columnHeaders,',',importedData.textdata{counter}); end % write column headers to new file dlmwrite('textfile_updated.txt',columnHeaders,'Delimiter','','newline','pc') % append all but last line of data to new file for dataCounter = 1:(size(importedData.data,2)-1) dlmwrite('textfile_updated.txt',importedData.data(dataCounter,:),'Delimiter',',','newline','pc','-append') end % append last line of data to new file, not % creating new line at end dlmwrite('textfile_updated.txt',importedData.data(end,:),'Delimiter',',','-append')

    Read the article

  • Bash Read Array from External File

    - by jmituzas
    I have setup a Bash menu script that also requires user input. These inputs are wrote (appended to) a text file named var.txt like so: input[0]='192.0.0.1' input[1]='username' input[2]='example.com' input[3]='/home/newuser' Now what I am trying to accomplish is to be able to read from var.txt from a script kinda like this: useradd var.txt/${input[1]} now I know that wont work just using it for an example. Thanks in Advance, Joe

    Read the article

< Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >