lines

Get uniq random lines from file and write them to another file using php

痞子三分冷 提交于 2019-12-14 01:58:58
问题 I have file consists of 10000 different lines. I need to take 100 random uniq lines from this file and write them to another file. What is the easiest way to do it using php? 回答1: A naive way: $lines = file('somefile.txt'); shuffle($lines); $random_lines = array_slice($lines, 0, 10); Note: This completely disregards system resource considerations. 回答2: A faster solution larger lines function m1($file) { $fp = fopen($file, "r"); $size = filesize($file); $list = array(); $n = 0; while ( true )

amchart add labels in between grids

一个人想着一个人 提交于 2019-12-13 16:25:07
问题 I need to add labels with difference of 10 in both axis( one each between the grid ), WITHOUT compromising the present number of grids.So the number of grid lines should stay 11 and number of labels will go up to 21. Hope that clears my query.Above is my chart, and this is the code - var chart = AmCharts.makeChart("chartdiv", { "type": "xy", "dataProvider": json, "valueAxes": [ { "id":"my_y", "autoGridCount": false, "position": "right", "tickLength":0, "gridThickness":0.25, "minimum":-100,

Drawing curved lines to connect elements on web page

坚强是说给别人听的谎言 提交于 2019-12-13 12:32:02
问题 I have been tasked with turning this rough idea into a live page. While I have a basic structure established, I am wondering the best way to go about creating the curved lines that connect the months. Should I just create images and over lay them? Is there a way to draw them with some kind of scripting/coding? Canvas? I don't know the best way to do this. 回答1: I just put this together to show you that it is very possible and there are probably other ways to do it. #upper-line { border: solid

Read WORDS (not char) from file without empty lines in C - not duplicated [duplicate]

☆樱花仙子☆ 提交于 2019-12-13 09:54:13
问题 This question already has an answer here : Read text from file skipping any spaces or empty lines (1 answer) Closed 5 years ago . Hi. I need to read several files without empty lines between words.They can have different layouts, such as 1.txt or 2.txt: 1.txt: treg hreger ig srg fre ig lre eg 2.txt: lregreg igregr kreggerg ereherh tershs hsehsteh asreh treshse How do i do that ? How can I count the number of words in the fastest way? I just have the following code: #include <stdio.h> #include

Slow and smooth drawing lines python matplotlib

独自空忆成欢 提交于 2019-12-13 08:47:24
问题 I'm using matplotlib for drawing graphs such as smooth lines. it is not problem to draw for me, but I have problems with animations. import numpy as np import random as random from matplotlib import pyplot as plt from matplotlib import animation So, i have array, such as: a = [0,1,2,4,5,8,9,12,14,18,22,17,30,37,29,45] And I need to draw it smooth point-to-point. Now I have this strings: for i in range(len(a)-1): desty = np.append(desty,np.linspace(a[i],a[i+1],n)) destx = np.append(destx,np

Toggle data based on checkbox value with morris.js

穿精又带淫゛_ 提交于 2019-12-13 04:43:59
问题 I'm getting trouble in making what I want morris.js charts to do. My goal is to be able to toggle specific lines based on input[type=checkbox] value. So far here's what I have done: JS code var morris = Morris.Line({ element: 'line-example', data: [ { y: '2006', a: 100, b: 90 }, { y: '2007', a: 75, b: 65 }, { y: '2008', a: 50, b: 40 }, { y: '2009', a: 75, b: 65 }, { y: '2010', a: 50, b: 40 }, { y: '2011', a: 75, b: 65 }, { y: '2012', a: 100, b: 90 } ], xkey: 'y', ykeys: ['a', 'b'], labels: [

Delete lines VBA macro takes a significant amount of time

拥有回忆 提交于 2019-12-13 04:35:14
问题 I have a macro that deletes lines based on a certain value in a column and then sorts them. It works fine. However, the worksheet starts with about 4000 rows and the macro ends up deleting about 2000 of them and it takes 1 minute 25 seconds to do it. I'm wondering if there's something I can do that will make it take a lot less time. Here's the code: 'remove numbers that are not allowed based on values in "LimitedElements" worksheet For i = imax To 1 Step -1 a = Sheets("FatigueResults").Cells

Storing lines of file into array

家住魔仙堡 提交于 2019-12-12 18:24:28
问题 So I'm pretty new to Perl, only been learning it for 1 week. I'm trying to read only a specific range of lines into an array. If I print $_ inside the if statement, it list exactly what i want stored into my array. But storing $_ into my array and then print @array outside the while shows nothing. I'm not sure what I should do. Reason why I'm trying to store it into an array is too get certain information from the columns, therefore needing an array to do so. Thanks for your help. Its

is there any way to ignore reading in certain lines in a text file?

此生再无相见时 提交于 2019-12-12 17:37:48
问题 I'm trying to read in a text file in a c# application, but I don't want to read the first two lines, or the last line. There's 8 lines in the file, so effectivly I just want to read in lines, 3, 4, 5, 6 and 7. Is there any way to do this? example file USE [Shelley's Other Database] CREATE TABLE db.exmpcustomers( fName varchar(100) NULL, lName varchar(100) NULL, dateOfBirth date NULL, houseNumber int NULL, streetName varchar(100) NULL ) ON [PRIMARY] EDIT Okay, so, I've implemented Callum

Read lines from a text file into variables

回眸只為那壹抹淺笑 提交于 2019-12-12 10:27:15
问题 I have two different functions in my program, one writes an output to a txt file (function A) and the other one reads it and should use it as an input (function B). Function A works just fine (although i'm always open to suggestions on how i could improve). It looks like this: def createFile(): fileName = raw_input("Filename: ") fileNameExt = fileName + ".txt" #to make sure a .txt extension is used line1 = "1.1.1" line2 = int(input("Enter line 2: ") line3 = int(input("Enter line 3: ") file =