I'm looking for a regex that will parse a line at a time from a csv file. basically, what string.readline() does, but it will allow line breaks if they are within double quotes.
or is there an easier way to do this?
Alright, PHP is throwing this error at me (in the log) when I run the code mentioned below:
Error
mysql_num_rows() expects parameter 1 to be resource, string given in (place) on line 10
Line 9-11
$queryFP = ("SELECT * FROM db");
$countFP = mysql_num_rows($queryFP);
$aID = rand(1, $countFP);
I think it has something to do with the $queryFP's syntax, but I'm not completely sure how to fix it since $queryFP's syntax is the simplest query I've ever seen.
I am using a notes client(v 7.0). I created a mail account with email id [email protected] in this client(obviously on domino server also). I want to auto reply to the mail which is sent to [email protected] with same subject line which must be appended with ";SUCCESS" at the end of subject line.
I want to split the /n from my string in Java. For example, I have one String field which has 2 lines space ( /n). I have to find out lines ( wherever mopre than one lines is coming) and should replace with one line spaces.
"This is Test Message
thanks
Zubair
"
From the above example, there are more spaces between "This is Test Message" and "thanks". So i want to reduce as only one line instead of 2 lines.How to do that?
import sys
import md5
from TOSSIM import *
from RadioCountMsg import *
t = Tossim([]) #The Tossim object is defined here
m = t.mac()#The mac layer is defined here , in which the communication takes place
r = t.radio()#The radio communication link object is defined here , as the communication needs Rf frequency to transfer
t.addChannel("RadioCountToLedsC", sys.stdout)# The various channels through which communication will take place
t.addChannel("LedsC", sys.stdout)
#The no of nodes that would be required in the simulation has to be entered here
print("enter the no of nodes you want ")
n=input()
for i in range(0, n):
m = t.getNode(i)
m.bootAtTime((31 + t.ticksPerSecond() / 10) * i + 1)
#The booting time is defined so that the time at which the node would be booted is given
f = open("topo.txt", "r") #The topography is defined in topo.txt so that the RF frequencies of the transmission between nodes are are set
lines = f.readlines()
for line in lines:
s = line.split()
if (len(s) > 0):
if (s[0] == "gain"):
r.add(int(s[1]), int(s[2]), float(s[3])) #The topogrography is added to the radio object
noise = open("meyer-heavy.txt", "r") #The noise model is defined for the nodes
lines = noise.readlines()
for line in lines:
str = line.strip()
if (str != ""):
val = int(str)
for i in range(0, 4):
t.getNode(i).addNoiseTraceReading(val)
for i in range (0, n):
t.getNode(i).createNoiseModel() #The noise model is created for each node
for i in range(0,n):
t.runNextEvent()
fk=open("key.txt","w")
for i in range(0,n):
if i ==0 :
key=raw_input()
fk.write(key)
ak=key
key=md5.new()
key.update(str(ak))
ak=key.digest()
fk.write(ak)
fk.close()
fk=open("key.txt","w")
plaint=open("pt.txt")
for i in range(0,n):
msg = RadioCountMsg()
msg.set_counter(7)
pkt = t.newPacket()#A packet is defined according to a certain format
print("enter message to be transported")
ms=raw_input()#The message to be transported is taken as input
#The RC5 encryption has to be done here
plaint.write(ms)
pkt.setData(msg.data)
pkt.setType(msg.get_amType())
pkt.setDestination(i+1)#The destination to which the packet will be sent is set
print "Delivering " + " to" ,i+1
pkt.deliver(i+1, t.time() + 3)
fk.close()
print "the key to be displayed"
ki=raw_input()
fk=open("key.txt")
for i in range(0,n):
if i==ki:
ms=fk.readline()
for i in range(0,n):
msg=RadioCountMsg()
msg.set_counter(7)
pkt=t.newPacket()
msg.data=ms
pkt.setData(msg.data)
pkt.setType(msg.get_amType())
pkt.setDestination(i+1)
pkt.deliver(i+1,t.time()+3)
#The key has to be broadcasted here so that the decryption can take place
for i in range(0, n):
t.runNextEvent();
this code gives me error here key.update(str(ak)) . when i run a similar code on the python terminal there is no such error but this code pops up an error . why so?
Hello everyone,
I'm not sure if this is the right forum to post this question. But I'm just hoping someone here might have used log4net in the past, so hoping to get some help.
I'm using log4net to log my exceptions. The configuration settings look like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<log4net debug="false">
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\Logs\sample.log" />
<appendToFile value="true"/>
<rollingStyle value="Size"/>
<maxSizeRollBackups value="10"/>
<maximumFileSize value="10MB"/>
<staticLogFileName value="true"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5level %date %logger.%method[line %line] - %message%newline"/>
</layout>
</appender>
<root>
<level value="INFO"/>
<appender-ref ref="RollingLogFileAppender"/>
</root>
</log4net>
</configuration>
I started out by adding this configuration to web.config, but I got an error (VS studio could not find a schema for log4net-"Could not find schema information for the element log4net"). So I followed this link (http://stackoverflow.com/questions/174430/log4net-could-not-find-schema-information-messages) and configured my settings in a separate xml file and added the following line of code in my AssemblyInfo.cs:
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "xmlfile.xml", Watch = true)]
And in the actual code, I placed this line:
public void CreateUser(String username, String password)
{
try
{
log.Info("Inside createuser");
//code for creating user
}
catch(exception e)
{
log.Info("something happened in create user", e);
}
}
The problem is that the log file is not being created. I can't see anything inside C:\Logs. Can anybody tell me what I'm doing wrong here?
Any suggestions/inputs will be very helpful.
Thank you all in advance.
Hallo,
i have a webdynpro containing a table displaying numerous lines. after the user clicks the delete button i want to delete the selected line of the table.
my problem right now is, that i don't know how to implement this in the event-call.
How can i identify the selected line of the table?
Best regards
Philipp
Domain name: textbox
check box .com
submit
Warning: fsockopen() [function.fsockopen]: unable to connect to whois.crsnic.net:43 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ) in C:\xampp\htdocs\check domain.php on line 35
Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\check domain.php on line 35
Is there a command line program that pretty-prints (that is, indents, adds line breaks to) HTML5 code?
tidy does too much for me (heck, it alters my doctype!), vim too little. What do you use to make your HTML5 code look beautiful?
I have a file in which each line contains two numbers. The problem is that the two number are separated by a space, but the space can be any number of blank spaces. either one, two, or more. I want to read the line and store each of the numbers in a variable, but I'm not sure how to tokenize it.
i.e
1 5
3 2
5 6
3 4
83 54
23 23
32 88
8 203
Most popular browsers, while rendering an image, they display it line-by-line top-to-bottom as it loads.
I have a requirement that a wait gif should be displayed while the image is loading.
When the image is fully loaded then it should be displayed instead of the wait gif.
How does a lexer solve this ambiguity?
/*/*/
How is it that it doesn't just say, oh yeah, that's the begining of a multi-line comment, followed by another multi-line comment.
Wouldn't a greedy lexer just return the following tokens?
/*
/*
/
I'm in the midst of writing a shift-reduce parser for CSS and yet this simple comment thing is in my way. You can read this question if you wan't some more background information.
I keep hearing that branching in git is so much easier than in SVN, because it's easier to merge the branch back to trunk/master. I've read some tutorials, but they only covered basic merge conflicts ("Alice changed line 8 of code.cpp and at the same time Bob changed line 8 of code.cpp...") and there are no differences between SVN and all other distributed source control systems.
Can you give me the examples of changes in branch that would cause troubles in SVN repository, but would be handled gracefully by git?
I'm looking for a command line program that pretty-prints (that is, indents, adds line breaks to, harmonizes the whitespace of) HTML5 code.
It has to run under Linux (in case you're interested, I want to use it as an filter for nanoc).
tidy does too much for me (heck, it alters my doctype!), vim too little. What do you use to make your HTML5 code look beautiful?
Maybe there is a way to make tidy cooperate and not alter anything?
my apologies in advance for a python and json nubie question. json seems to be hiccuping on the following statements:
{"delete":{"status":{"id":12600579001,"user_id":55389449}}}
code snippet:
temp = json.loads(line)
text = temp['text']
I get the following error output when the above code snippet encounters lines similar to the above json 'dictionary':
text = temp['text']
KeyError: 'text'
Is it because there is no "text" key in the line or because "delete" is not in the dictionary?
Disclaimer: I'm a newbie at scripting in perl, this is partially a learning exercise (but still a project for work). Also, I have a much stronger grasp on shell scripting, so my examples will likely be formatted in that mindset (but I would like to create them in perl). Sorry in advance for my verbosity, I want to make sure I am at least marginally clear in getting my point across
I have a text file (a reference guide) that is a Word document converted to text then swapped from Windows to UNIX format in Notepad++. The file is uniform in that each section of the file had the same fields/formatting/tables.
What I have planned to do, in a basic way is grab each section, keyed by unique batch job names and place all of the values into a database (or maybe just an excel file) so all the fields can be searched/edited for each job much easier than in the word file and possibly create a web interface later on.
So what I want to do is grab each section by doing something like:
sed -n '/job_name_1_regex/,/job_name_2_regex/' file.txt --how would this be formatted within a perl script?
(grab the section in total, then break it down further from there)
To read the file in the script I have open FORMAT_FILE, 'test_format.txt'; and then use foreach $line (<FORMAT_FILE>) to parse the file line by line. --is there a better way?
My next problem is that since I converted from a word doc with tables, which looks like:
Table Heading 1 Table Heading 2
Heading 1/Value 1 Heading 2/Value 1
Heading 1/Value 2 Heading 2/Value 2
but the text file it looks like:
Table Heading 1
Table Heading 2Heading 1/Value 1Heading 1/Value 2Heading 2/Value 1Heading 2/Value 2
So I want to have "Heading 1" and "Heading 2" as a columns name and then put the respective values there. I just am not sure how to get the values in relation to the heading from the text file. The values of Heading 1 will always be the line number of Heading 1 plus 2 (Heading 1, Heading 2, Values for heading 1). I know this can be done in awk/sed pretty easily, just not sure how to address it inside a perl script.
After I have all the right values and such, linking it up to a database may be an issue as well, I haven't started looking at the way perl interacts with DBs yet.
Sorry if this is a bit scatterbrained...it's still not fully formed in my head.
As the author has forgotten to add a detailed usage listing (or I can't find it), I wonder if anyone knows anything about the command-line options accepted by the FernFlower decompiler application.
You can find an online version here: http://www.reversed-java.com/fernflower/
I'm trying to enable/disable all these flags that are present on that webpage.
The actual command-line JAR can be found here: https://github.com/Bukkit/Bukkit-MinecraftServer
Many thanks
Nik
hi ive got a working sms receiver but when i try to load another class using:
Intent intent = new Intent(SMSReceiver.this, SMSNotifier.class);
startActivityForResult(intent, 0);
i get the error:
The constructor Intent(SMSReceiver, Class<SMSNotifier>) is undefined
for the first line and:
The method startActivityForResult(Intent, int) is undefined for the type SMSReceiver
for the second line
id really appreciate some advice as to whats going wrong
thanks,
ng93
Hey, I've been trying to get the xWinForms 3.0 library (a library with forms support in xna) working with my C# XNA Game project but I keep getting the same problem.
I add the reference to my project, put in the using statement, declare a formCollection variable and then I try to initialize it.
whenever I run the project I get stopped on this line:
formCollection = new FormCollection(this.Window, Services, ref graphics);
it gives me the error:
"
System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="Microsoft.Xna.Framework"
StackTrace:
at Microsoft.Xna.Framework.Graphics.VertexShader..ctor(GraphicsDevice graphicsDevice, Byte[] shaderCode)
at Microsoft.Xna.Framework.Graphics.SpriteBatch.ConstructPlatformData()
at Microsoft.Xna.Framework.Graphics.SpriteBatch..ctor(GraphicsDevice graphicsDevice)
at xWinFormsLib.FormCollection..ctor(GameWindow window, IServiceProvider services, GraphicsDeviceManager& graphics)
at GameSolution.Game2.LoadContent() in C:\Users\Owner\Documents\School\Year 3\Winter\Soen 390\TeamWTF_3\SourceCode\GameSolution\GameSolution\Game2.cs:line 45
at Microsoft.Xna.Framework.Game.Initialize()
at GameSolution.Game2.Initialize() in C:\Users\Owner\Documents\School\Year 3\Winter\Soen 390\TeamWTF_3\SourceCode\GameSolution\GameSolution\Game2.cs:line 37
at Microsoft.Xna.Framework.Game.Run()
at GameSolution.Program.Main(String[] args) in C:\Users\Owner\Documents\School\Year 3\Winter\Soen 390\TeamWTF_3\SourceCode\GameSolution\GameSolution\Program.cs:line 14
InnerException:
"
In a project I downloaded that used the xWinForms, I put the following code in and it compiled and ran no error.
but when I put it in my project I get the error.
Am I making some stupid mistake about including dlls or something? I've been at this for hours and I can't seem to find anything that would cause this.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using xWinFormsLib;
namespace GameSolution
{
public class Game2 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
FormCollection formCollection;
public Game2()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
formCollection = new FormCollection(this.Window, Services, ref graphics);
}
protected override void Update(GameTime gameTime)
{
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
base.Draw(gameTime);
}
}
}
Any help would be greatly appreciated ._.
Hi all,
I use the line below in my C# winform app, this works great but occasionally if the program is being run from the command line I get an error that the config.xml file cannot be found. This is because the 'working directory' is different (I think), I need to say "load config.xml from current directory", how would I do this?
docXML.Load("config.xml");
Thanks
Jonathan
As usual I typed sudo Library/uninstall-devtools --mode=all
It uninstalled the first version (Beta) properly.
Tried the same thing on the older Stable Version which I have installed to "XCode Stable"
Getting this error
Use of uninitialized value $dir_name in substitution (s///) at Library/uninstall-devtools line 153.
Use of uninitialized value $developer_dir in concatenation (.) or string at Library/uninstall-devtools line 120
Anyone else facing this problem? Can I just trash the installation folder?
The language Google Desktop gadgets use resembles JavaScript, but it's different in subtle ways. For example, I saw this line in a gadget:
options(HISTORY_OPTIONS_NAME) = items_.join("|");
which looks like it's assigning to a function call. That's just not OK in JavaScript... what language is this? And what exactly is that line doing?
First of all, for those that don't know pashua is a tool for creating native Aqua dialog windows.
An example of what a window config looks like is
# pashua_run()
# Define what the dialog should be like
# Take a look at Pashua's Readme file for more info on the syntax
conf="
# Set transparency: 0 is transparent, 1 is opaque
*.transparency=0.95
# Set window title
*.title = Introducing Pashua
# Introductory text
tb.type = text
tb.default = "HELLO WORLD"
tb.height = 276
tb.width = 310
tb.x = 340
tb.y = 44
if [ -e "$icon" ]
then
# Display Pashua's icon
conf="$conf
img.type = image
img.x = 530
img.y = 255
img.path = $icon"
fi
if [ -e "$bgimg" ]
then
# Display background image
conf="$conf
bg.type = image
bg.x = 30
bg.y = 2
bg.path = $bgimg"
fi
pashua_run "$conf"
echo " tb = $tb"
The problem is, Pashua can't really get output from stdout, but it can get arguments.
Following on from what Dennis Williamson posted here. What ideally it should do is generate an output file based on information from a text file, To executed in pashua_run ore add the pashua_run around the window argument:
count=1
while read -r i
do
echo "AB${count}.type = openbrowser"
echo "AB${count}.label = Choose a master playlist file"
echo "AB${count}.width=310"
echo "AB${count}.tooltip = Blabla filesystem browser"
echo "some text with a line from the file: $i"
(( count++ ))
done < TEST.txt >> long.txt
SO the output is
AB1.type = openbrowser
AB1.label = Choose a master playlist file
AB1.width=310
AB1.tooltip = Blabla filesystem browser
some text with a line from the file: foo
AB2.type = openbrowser
AB2.label = Choose a master playlist file
AB2.width=310
AB2.tooltip = Blabla filesystem browser
some text with a line from the file: bar
AB3.type = openbrowser
AB3.label = Choose a master playlist file
AB3.width=310
AB3.tooltip = Blabla filesystem browser
some text with a line from the file: dev
AB4.type = openbrowser
AB4.label = Choose a master playlist file
AB4.width=310
AB4.tooltip = Blabla filesystem random
So if there is a clever way to get the output of that and place it into pashua run would be cool, on the fly: I.E load te contents of TEST.txt and generate the place it into pashua_run, I've tried using cat and opening the file... but because it's in Pashua_run it doesn't work, is there a smart way to break out then back in?
Or the second way which I was thinking, was create get the output then append it into the middle text file containing the pashua runtime, then execute it, maybe slightly hacky, but I would imagine it will do the job.
Any ideas?
++ I know I probably could make my life a lot easier, by doing this in actionscript and cocoa, although at present don't have time for such a learning curve, although I do plan to get round to it.
Has anyone run across a quality library that will parse, line by line, CSV, tab-delimited, and Excel files?
I've started to do it manually but have noticed some of the intricacies in parsing a comma-delimited file. Such as situations where a cell has a comma in it as part of the data (blah,\"LastName, Jr.\",blah,blah).
I thought this will be trivial but I can't get this to work.
Assume a line in a CSV file:
"Barak Obama", 48, "President", "1600 Penn Ave, Washington DC"
string[] tokens = line.split(',')
I expect this:
"Barak Obama"
48
"President"
"1600 Penn Ave, Washington DC"
but the last token is
'Washington DC' not
"1600 Penn Ave, Washington DC".
Is there an easy way to get the split function to ignore the comma within quotes?