Menu
  • HOME
  • TAGS

How to get specific rows in a txt file in PHP?

php,sql,text

<?php $File = "file.txt"; // I assume your file has 57th and 65th line $fhandle = fopen($File, 'r'); while(!feof($fhandle)) // until end of file { $data[] = fgets($fhandle); // place each line to array //Do whatever you want with the data in here //This feeds the file into an array...

Get string (file name) of a given extension from within a text file

c#,string,file,text

If you know the extensions that can show up you can use the following solution with a regex: //regex for file name with known extensions Regex r = new Regex("^.*\\.(ext|doc|PUT_OTHER_EXTENSIONS_HERE)$"); var lines = File.ReadAllLines(FILE_PATH); var res = lines.Where(x => !string.IsNullOrWhiteSpace(x) && r.Match(GetFirstEntry(x)).Success) .Select(x => GetFirstEntry(x)); where GetFirstEntry : /// <summary>...

How to provide default font height or content when

or has no characters?

javascript,html,css,text,height

Question 2 The width behavior of p versus span is due to the CSS specification for the width property. width does not apply to non-replaced inline elements (span), so p being a block level elements, takes on the width value. Note that, if you apply display: inline-block to a span,...

Unexpected Symbol in As Formula, Can't Find

r,string,text,syntax-error,formula

The <text>:2:10080 is giving you the location of the error. 2nd line, 10080th character. Consider: parse(text="1 + 1 + 2\n a - 3 b") # Error in parse(text = "1 + 1 + 2\n a - 3 b") : # <text>:2:8: unexpected symbol Here, the error is with b, which...

jQuery text animation from right to left

jquery,animation,text

Just add a height to ul ul.social-media-channels { margin: 0; padding:0; position:relative; float:right; margin-right:15px; display:none; height:20px; li{ display:inline; } } } http://codepen.io/anon/pen/JdyQRG...

Why is this basic python program not working?

python,email,text,organization

Your problem is this line subbed = line[-3:] This returns the following: ok\n or il\n Thus, your if statement checking if subbed == 'ok' will fail every time. You can fix this by only taking the last two characters, after stripping the newline: subbed = line.strip()[-2:] My original answer didn't...

How to display text in browsers tab bar in a javaserver page [closed]

html,jsp,browser,text,tabs

Browser tabs display the FavIcon and the <title> of the page. You can't really display multiple lines in a browser tab, though you could separate information you want to display in it with a -, which is pretty common practice. For example: <html> <head> <title>My Title - Awesome Web Page</title>...

Verilog Input Text Parsing using Python Regex

python,regex,text,extract,verilog

.*?\binput\b.*? (\S+), You can use this.inputs.append(input_mod.group(1))This will take care of everything in between input and the last non space string before ,.See demo. https://regex101.com/r/nS2lT4/4#python...

Unable to modify variables from separate thread

c#,multithreading,winforms,text,file-io

You've got multiple problems here, the use of the File is probably not thread-safe. your method does not repeat your are Sleep()ing on a Thread You can solve all of them by ditching the Thread and use a simple Timer. ...

Is it possible to change ONE line in a txt file WITHOUT reading and writing the whole file (Java)?

java,file,text,replace,line

Short answer: no. Long answer: Not really. If you know that the text you're inserting directly replaces the text you're removing you could perform a substitution by seeking to the portion of the file, reading a small block, substituting the new text and replacing that block. This would work for...

How do i split text to a different column or remove a text from the original column?

excel,vba,excel-vba,text,split

So test that : Sub SplitValues() Dim aSplit As Variant With ActiveSheet For I = 2 To Cells(.Rows.Count, "D").End(xlUp).Row aSplit = Split(Cells(I, "D"), " ", 2) 'Write in D and E columns (erase data already in D) Cells(I, "D") = aSplit(0) Cells(I, "E") = aSplit(1) 'Write in E and F...

Wrapper for the matlab to read sparse data file

matlab,sorting,text,awk,libsvm

Store all the info in an array a[] and then sort using indices: awk '{delete a for (i=2; i<=NF; i++) a[$i+0]=$i n=asorti(a, sorted, "@ind_num_asc") printf "%s%s", $1, OFS for (i=1;i<=n;i++) printf "%s%s", a[sorted[i]], (i==n?ORS:OFS)}' file Explanation This uses asorti() and @ind_num_asc to define the ordering mode. For every line, we...

Make text appear on hover

html,css,text,hover

#con { width:1024px; height:670px; background-color: #161717; } #box1 { float:left; font-size:25px; width:388px; height:477px; background-image: url(media/trying1.png); background: #ccc; /*for example*/ margin-left: 120px; margin-top: 90px; } #text1{ opacity: 0; transition: all 0.5s; } #box1:hover #text1{ opacity: 1; } <div id="con"> <div id="box1"> <p id="text1"> <a href="url">DESTINATION</a>SS </p> </div> ...

How can I create large ASCII text from a string?

html,text

You can use ASCII text generator like FIGlet which uses FIGlet fonts. TOIlet is like FIGlet and can use FIGlet fonts but as additional capabilities including Unicode handling, colour fonts, filters and various export formats. Specific logos may need to be created as their own font. Here are some links:...

Save user input into a Text widget Tkinter when using classes

python,text,tkinter

You need to save a reference to the text widget, and pass parameters to the get method, to tell it what range of data to get: self.bottom = ScrolledText(m2, wrap=WORD) ... print self.bottom.get("1.0", "end-1c") ...

Rails. Why does my submit button say Create vs. Update depending on

ruby-on-rails,button,text,submit

It's defined in the Rails Framework. Whenever the new method is called the params[:action] = 'new', So, for the form we use f.submit. This f object is the instance of that new method. Thus the framework decides to show the button name 'New Article'. Article is the object and new...

Python - Select specific value from test file

python,file,text

You could split the text and have a list of lists, where each sub list is a row, then pluck whatever you need from the list using rows[row - 1][column - 1]. f = open('test.txt', 'r') lines = f.readlines() f.close() rows = [] for line in lines: rows.append(line.split(' ')) print...

How can I map keys in Insert mode that contains Carriage Return in it?

vim,text,insert,editor,vi

For an insert mode mapping, you need :imap; :set is for setting Vim options. Ctrl + Enter is written as <C-CR>; cp. :help key-notation. Ergo: :inoremap <C-CR> <Esc>o Note that this key combination mostly only works in GVIM, as most terminals do not send different keycodes for Enter in combination...

Adding custom text to UITextField buffer

ios,objective-c,text,buffer,homekit

You can populate the iPhone clipboard using below code. Put this code to a suitable place in your code. UIPasteboard *clipboard = [UIPasteboard generalPasteboard]; clipboard.string = @"<Assign Some value>"; ...

Replace bigrams based on their frequency in Scala and Spark

scala,text,apache-spark

def getNgrams(sentence): out = [] sen = sentence.split(" ") for k in range(len(sen)-1): out.append((sen[k],sen[k+1])) return out if __name__ == '__main__': try: lsc = LocalSparkContext.LocalSparkContext("Recommendation","spark://BigData:7077") sc = lsc.getBaseContext() ssc = lsc.getSQLContext() inFile = "bigramstxt.txt" sen = sc.textFile(inFile,1) v = 1 brv = sc.broadcast(v) wordgroups = sen.flatMap(getNgrams).map(lambda t: (t,1)).reduceByKey(add).filter(lambda t: t[1]>brv.value) bigrams...

How can I get common rows that exist in at lest two files or more?

bash,text,text-files

Using awk: awk ' FNR==1{ #Header line: fn[++i]=FILENAME; # record filenames fn[0]=$0; # & file header } (FNR>1){ # For lines other than header lines list[$0]++; # Record line file_list[$0 FILENAME]++; # Record which file has that line } END{ for(t=0;t<=i;t++) printf "%s\t", fn[t]; # Print header & file names...

How do I make the text of one label node take up 2 lines?

xcode,string,swift,text,sklabelnode

You can create your own method to display multi line text as follow: import SpriteKit class GameScene: SKScene { override func didMoveToView(view: SKView) { displayMultiLineTextAt(CGRectGetMidX(self.frame) - 100, y: CGRectGetMidY(self.frame) + 50, align: SKLabelHorizontalAlignmentMode.Left, lineHeight: 20.0, text: "Welcome to StackOverFlow!\nThe weather today is going to\nbe partly cloudy with a chance\nof rain.")...

Align rows in text file with command line

text,command-line

This solution creates lots of temp files, but cleans up after. # put each paragraph into it's own file: awk -v RS= '{print > sprintf("%s_%06d", FILENAME, NR)}' data.txt # now, join them, and align the columns join data.txt_* | column -t | tee data.txt.joined # and cleanup the temp files...

how to change text direction to the right slide of switch in android?

android,text,switch-statement

AFAIK thats not doable, you can try the following <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <Switch android:id="@+id/switch_gprs" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="false" android:paddingBottom="15dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="false" android:paddingBottom="15dp" android:layout_toRightOf="@+id/switch_gprs"...

Input boxes not lining up

html,css,text,input,form-submit

Add this CSS3 box-sizing Property in your stylesheet. * { box-sizing: border-box; } ...

Error: Getting symbols in python output

python,python-2.7,text,file-io,editor

You need to close and re-open your file. print "This is a simple text editor" from sys import argv script, name = argv print "You have selected the file : %s" %name print "Opening the file...." t = open(name, 'r+') print "The contents of the file are" print t.read() t.close()...

Apple Script : Cleaning textedit text

text,applescript,textedit

Multiple text item delimiter calls can be tricky for AppleScript. Try this: tell application "TextEdit" to set documentText to text of document 1 tell application "TextEdit" to set text of document 1 to my RemoveThis(documentText, {"Administration", "New Search", "Advanced", "Tips"}) to RemoveThis(txt, termList) repeat with eachTerm in termList set {oldTID,...

change the content of a select option

jquery,forms,select,text,options

If you specifically know that you want to change the second option element within the select, you can target it with :eq(): $('.myclass option:eq(1)').text('TWO'); Note that eq() works on a zero-based index, so 0 is the first element, 1 is the second and so on....

To make a particular part of my text clickable

android,redirect,text,clickable

Try and include the following in the TextView definition in XML file: <TextView ... android:autoLink="web"/> The docs of android:autoLink say: Controls whether links such as urls and email addresses are automatically found and converted to clickable links So for automatically finding links, the above may help. Try and see....

text show and hide with button php/js

php,jquery,text,hide,show

This will select and toggle all instances of dd on the entire page. $("button").click(function () { $("dd").slideToggle("slow"); }); This will select and toggle the intended instance of dd, closest to the button you pressed. $("button").click(function () { $(this).closest('dl').find('dd').slideToggle("slow"); }); It takes the button you actually pressed with ($this), finds the...

Extract lines from File2 already found File1

linux,text,awk,sed,grep

A more flexible tool to use would be awk awk 'NR==FNR{lines[$0]++; next} $1 in lines' Example $ awk 'NR==FNR{lines[$0]++; next} $1 in lines' file1 file2 H D A What it does? NR==FNR{lines[$0]++; next} NR==FNR checks if the file number of records is equal to the overall number of records. This...

Javascript show / hide on click multi ID

javascript,text,show-hide

According to HTML specification an id property of the element must be unique. You either need to assign different ids to each of your elements, or target them by some less restrictive parameter, such as class. <div id="wrap"> <p> <img src="http://riccardobernucci.com/riviera/images/thumbs/FFBB.jpg" alt=""/> <a href="#" id="example1-show" class="showLink" onclick="showHide('example1');return false;">+ INFORMAZIONI</a> </p>...

Python outputs a .txt file, which's format differs depending on the text editor I use to open it

python,text,output

That is a problem with notepad itself. It can't handle "Linux newlines" instead it only recognizes "windows newlinew", so you have to write \r\n and then you will see the linebreaks in notepad.

Changing a read-only file [on hold]

python,text

Yes, you are right, you can only read where you cannot write.

HTML make your own