FAQ Database Discussion Community


Python: iteration problems

python,text,iteration
I am performing text processing on a text file and have been trying to iterate into a for loop. fields = [1, 2, 3, 4, 5] i = 0 with open('file path', 'r') as f: for line in f: # while i is smaller than the number of fields (=5)...

Apple Script : Cleaning textedit text

text,applescript,textedit
I want to clear some text from a textedit text but its only half working for me tell application "TextEdit" set documentText to text of document 1 set {oldTID, my text item delimiters} to {my text item delimiters, "Administration"} set textBits to text items of documentText set my text item...

JQuery add a whitespace to each new text node to prevent clumping on extraction

jquery,text,whitespace
What I do is I want to transform <div id=master> Blah <span id=crap>Blah1</span> <div id=crap2>Blah2</div> <b>Blah3</b> </div> to <div id=master> Blah <span id=crap> Blah1 </span> <div id=crap2> Blah2 </div> <b> Blah3 </b> </div> because when I extract all the text from all elements inside master it becomes looking like this...

Unable to modify variables from separate thread

c#,multithreading,winforms,text,file-io
So I'm making a C# app which has to continuously read and display the contents of a text file, while allowing the user to enter something into a text box and append it to the end of that very file. I'm doing this by running my read method on a...

Python - Select specific value from test file

python,file,text
I'm absolute beginner in python, and I'd like to get field i.e. from 2nd column, 3rd row from text file like this: 176a AUGCACGUACGUA ACGUA AGUCU 156b GACUACAUGCAUG GCAUA AGCUA 172e AGCUCAGCUAGGC CGAGA CGACU (text is separated by spaces). is there any simple way to do that?...

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

xcode,string,swift,text,sklabelnode
I have this text below that is too long to fit on the screen when it runs. How can I make this 2 lines rather than one? myLabel.text = "The weather today is going to be partly cloudy with a chance of rain" ...

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

python,text,output
So I have some python code taht outputs some data to a .txt file like this: f3 = codecs.open(r'C:\Users\dimrizo\Desktop\PythonData\GTFS\routes.txt','w+',"UTF-8") f3.write('route_id,agency_id,route_short_name,route_long_name,route_desc,route_type,route_url,route_color,route_text_color\n') f3.write('blah,blah,blah,blah,blah,blah,blah,blah,blah\n') Problem is that if I open the produced file with the simple windows text editor the text is not properly formatted. The "\n" don't even count. If I open...

Changing a read-only file [on hold]

python,text
I need to change text documents. The way I've been doing it is making a new file, copying everything line by line from the old file and making changes on the way, then saving the new file as the old file's name. This becomes a problem when I only have...

Select/mark specific word in SWT Textfield

java,text,widget,swt
I've got an SWT Textfield with some text which is added automatically. Now I want to select a specific phrase in the text automatically, so that the user could replace this without the manual selection. But all I've found in the api is the selectAll() method, which works but selects...

Text justification C language

c,text,alignment
I have to solve a problem that involves left justification string length and leading zeros. I have the following table : BEGIN CLOSE CONCATENATE DELETE END INITIALIZE PRINT WRITE This is produced by a simple program. My problem is to find out how to convert it like that : It...

Stop text from leaking out of div [on hold]

html,css,text
I have some text which is contained in a div, however if it's too long, it leaks outside of the div and I don't want that. I dont want to use the overflow attribute and give it a scroll bar. Id like it to put the "..." at the end...

Corona sdk random text

text,random,sdk,corona
I`m have a problem because when i touch my button sometimes not appear my text... (Sorry for my English!) Code: function randomText(event) display.remove(mmDis) local a = {"Cristiano ronaldo jest najlepszy!","messi jest dobry!","lewandowski jest ok","diego lopez to bramkarz realu"} com = (a[math.random(1,#a)]) local mmDis = display.newText(tostring(com), display.contentWidth*0.57, display.contentHeight*0.7, display.contentWidth*0.9, display.contentHeight*0.8, "Impact",...

x axis text overlapping in matlab

matlab,text,overlap
My x axis text are overlapping. I am using this code-- clear all A=[1 2 3 4 5 6 7]'; b=1:length(A); figure(1) bar(A) title('Loss Diagram') xlabel('Loss factor') ylabel('kWh/year','fontsiz`enter code here`e',20) grid on set(gca,'Xtick',b,'XtickLabel',{'Horizntl Global Irr. ' 'Effective irr. on coll. ' 'Array nominal energy ' 'PV module loss ' 'charge...

DirectWrite align text center

c++,text,directx,direct2d,directwrite
I am trying to align center the text I have to draw. I use ID2D1RenderTarget::DrawTextLayout method. The problemn is that if I set the text horizontal alignment to DWRITE_TEXT_ALIGNMENT_LEADING (the default value) the text is drawn proberly, but if I change this value to DWRITE_TEXT_ALIGNMENT_CENTER the text is shifted right....

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

vim,text,insert,editor,vi
How can I map ctrl + enter to go to new line from anywhere in the current line in vim ? I just want to do it for insert mode. I tried :set <C-<CR>> <Esc>o but that doesn't seem to work....

Change ID in File

java,file,text,path,rename
Let's say I have this notepad file name: Company_XXX_768_JGH.txt Contents: Random Text Blah Blah Blah Network ID: 80801568 I need to change the ID last 4 numbers (1568) to (0003). So far I am able to read the whole, find the line with the number AND print a statement for...

How to tell Users that a Tooltip lies behind a Text/Textbox/Image, etc.?

windows,user-interface,text,tooltip,user-experience
In my U.I. I have a normal text headline that covers a block of checkboxes but without further information I'm scared of Users not knowing what to do with the window. So my idea was to put a tooltip in the headline to give Users information about the funktion of...

Reading text file in java using scanner

java,file,text,java.util.scanner
I am a beginner. Reading from text file in Java using a scanner. This code just to read the first 3 tokens isn't working: try{ Scanner scFile = new Scanner (new File ("readhere.txt")).useDelimiter("#"); String first = scFile.next(); String second = scFile.next(); int third = scFile.nextInt(); // error here. Why cant...

Read lines of a text file into an array

java,android,arrays,file,text
I would like to display a new quote randomly every time someone launch the app.In order to do that I was thinking of using a text file containing all the quotes, one at each line. I would like to know in android studio where should I put my text file...

Reference a Text File with relative path in Java with the IntelliJ IDEA

java,text,relative-path
I have a program that reads numbers from a .txt file. My problem is where to place this file, or how to reference it with a relative path to make this file accessible without using the absolute path.

Excel Function Error

excel,function,text
I am trying to create a cell from a Excel to show three values depending of a number from another cell. The function I use is =IF(H4<100;(TEXT(Probabil));(IF(H4<50;(TEXT(Sigur));(TEXT(Da)))) NOTE: The function outputs are in Romanian. Probabil means possible, Sigur means sure and Da means yes. I tried to use " before...

OutOfMemory exception thrown while writing large text file

c#,text,out-of-memory,file-writing
I want to generate a string and then write it in to a .txt file. The problem is I get OutOfMemory exceptions when I attempt to do so. The file is large (about 10000 lines). I use String.Format and loops to create the string. How can I write this to...

To make a particular part of my text clickable

android,redirect,text,clickable
I'm tring to make a particular part of my text clickable. Please see the below image for example: In this image "www.google.com" is placed inside an expandable listview. Can anyone please help me how I can make this text clickable so that it re-directs to its corresponding web page ArrayList<String>...

resize/scale text dynamically in andengine

android,text,andengine
I created a simple game where move the objects from one place to another and each moves increment count of moves in score table. After all objects are moved correct I want set opacity to screen and slowly resizing score from initial size(e.g. 15px) to whole screen(e.g. 50px). I load...

How can I wrap text in QGraphicsItem?

qt,text,word-wrap,qgraphicsitem
1) How can I wrap text in a QGraphicsTextItem to fit a fixed rectangle, with width and height ? Right now I am experimenting with creating a text, getting its bounding rectangle, and resizing it to fit the box - but I can't get wrapping. class TTT: public QGraphicsTextItem {...

Extract text from large file using RegEx?

c#,regex,text
I have a big file that has a bunch of data in it, but essentially what I would like to do is to grab only parts of it, let me explain what parts I'm interested in: (imagine "x" as an IP Address) (imagine "?" as any alphanumerical character /w any...

Can I put StreamReaders in a list? Or any other way to read a lot of text files at once?

c#,list,text,streamreader
I have a lot of text files and want to read them all by once, how do I do this? This is my code till now: List<StreamReader> lijst = new List<StreamReader>(); using (StreamReader qwe = new StreamReader("C:\\123.txt")) using (StreamReader qwer = new StreamReader("C:\\1234.txt")) lijst.Add(qwe); lijst.Add(qwer); But I get an ObjectDisposedException(Cannot...

Does “Text” in the HTML5 syntax mean “any character”?

html,html5,text,syntax
I wasn't able to find any restrictions what characters are allowed in Text does this imply that erverthing is allowed or are there restrictions that affect HTML documents in general? For example the Character Reference Section states that: The numeric character reference forms [...] are allowed to reference any Unicode...

How to read data separated by a ',' in a text file in C [duplicate]

c,file,csv,text,input
This question already has an answer here: Reading CSV from text file in C 4 answers I was wondering how to read data from a text file that has its data separated by a comma; for example line 1 of the text file says: (Name,Integer,Integer). So I tried using...

Add blank line before a certain phrase in a text file in Linux?

linux,text,grep,kali-linux
I'm using Kali Linux, trying to sort out some input from Nmap. Basically, I ran a scan from NMap, and need to extract specific pieces of information from it. I've got it to show everything I need using the following command: cat discovery.txt | grep 'Nmap scan report for\|Service Info:...

Making 3 columns of text aligned at the same height or line all the time even while re sizing window

html,css,text,alignment,height
CSS: I want to make 3 columns of text aligned at the same height or line all the time even when I resize the window. To illustrate what I am talking about please take a look at the images by following this link: https://drive.google.com/file/d/0BywbaHflqMTERFVrNF84YlBUbTg/view?usp=sharing The problem is that the third...

Parsing html using Selenium - class name contains spaces

python,html,parsing,selenium,text
I'm trying to parse some html using Selenium. The problem is that it raises error in case the class name contains spaces. Here is the tag I'm searching for: <p class="p0 ng-binding">text</p> I've tried these two options: result.find_element_by_class_name('departure').find_element_by_css_selector('p.p0 ng-binding').text result.find_element_by_class_name('departure').find_element_by_class_name('p0 ng-binding').text >>> selenium.common.exceptions.InvalidSelectorException: Message: The given selector p0 ng-binding is...

Removing the blank positions (x,y) from a text file in Python?

python,text
I'm working on object tracking from video files, I have 5 to 6 objects in each frame of the video. Due to some bugs in the code there are some frames that are skipped and show as blank spaces in the text file . Like below 5.0 2.3 5.4 5.2...

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

bash,text,text-files
I have seven test files. They look like following File 1 chr start end strand chr1 10525 10525 + chr1 10542 10542 + chr1 10571 10571 + chr1 10577 10577 + chr2 10589 10589 + chr2 565262 565262 + chr2 565397 565397 + chr3 567239 567239 + chr3 567312 567312...

Splitting a text file

python,text,split
I have a folder with a set of text documents. I want to split each document to two or three documents, each one should be 45-70kb. How сan I do it? I tried: def split_file(filename, pattern, size): with open(filename, 'rb') as f: for index, line in enumerate(f, start=1): with open(pattern.format(index),...

Adding custom text to UITextField buffer

ios,objective-c,text,buffer,homekit
Background: I have got a custom alert part of the HomeKit API. I'd like to allow the user to paste the code requested rather than inputting it manually. Whenever there is text in the buffer it is possible to paste it by tapping on the textfield. How can I add...

text show and hide with button php/js

php,jquery,text,hide,show
How can I apply the multiple texts? With a text it works: <dl> <dt> <img class="empfehlung-bild" style="max-width: 300px; height: auto; float: left; margin-right: 15px; margin-bottom: 15px;" src="<?php echo $bild; ?>" /> <h1><?php echo $title; ?></h1> <p> <?php echo $text; ?> </p><br/> <button id="<?php echo $i; ?>" style="float:right;">Details</button><br/><br/> </dt> <dd style="float:left;">...

Why is this basic python program not working?

python,email,text,organization
Well the program is supposed to check if the it sees an "ok" next to the email and if it does spit out the email in another txt file. Input txt file: .......[email protected],ok .......[email protected],fail .......[email protected],fail .......[email protected],fail .......[email protected],ok .......[email protected],fail .......[email protected],fail .......[email protected],ok python code is: readEmails = open("C:\\Users\\Greg\\Desktop\\rewriteEmails.txt","r") writeEmails = open("C:\\Users\\Greg\\Desktop\\OutputEmails.txt","w") for...

Win 8 App Get text from datatemplate listview

listview,text,windows-8
I'm trying to learn how to make datatemplate in listviews in my win 8 app I have the following code in my Xaml code <!-- Vertical scrolling item list --> <ListView x:Name="itemListView" Margin="0,4.714,10,0.429" ItemsSource="{Binding Source={StaticResource itemsViewSource}}" SelectionChanged="itemListView_SelectionChanged" Loaded="itemListView_Loaded" Grid.Row="4" Tapped="itemListView_Tapped_1"> <ListView.ItemTemplate> <DataTemplate> <Grid Height="110" Margin="6"> <Grid.ColumnDefinitions>...

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

c#,string,file,text
I apologize if the question title is a little confusing, but let's say a text file contains the following data: Sample 'Line1 1 'Line2 2 'ProjectCount FileA.ext 'Projects( 1) 0 'SortTermCount FileB.ext 'Projects( 2) 0 'SortTermCount ... I know the extension name that exists as a string within the file...

HTML make your own