For performance, last I checked, re is faster than nre by a lot.
Ok re: not a crash. I learned the best way to do SQL in Nim is first via the
command-line utility to test the syntax and methods, when satisfied then add to
Nim. The Nim error messages as you say something wrong here is difficult to
debug for a new user, the sqlite3 utility gives more info and
Alright, I thought SQL gracefully ignored adding a duplicate key but guess not.
I've added this function:
proc exists(database: Database, id: string): bool =
result = if len(database.db.getValue(sql"SELECT id FROM Pages WHERE id =
?;", id)) > 0: true else: false
I'm new to SQL so don't know if I'm doing something wrong or this is a bug.
The following produces runtime error: "Error: unhandled exception: unable to
close due to unfinalized statements or unfinished backups [DbError]"
The code is mostly adapted from 'Nim in Action'. The first run on db
GNU awk - sometimes considered a "toy" language but far from it these days.
I've done entire websites, http servers and OAuth. The syntax is easier than
Nim, runs nearly as fast, and being a single executable and POSIX can be found
pre-installed most places. Used for all my scripting work and
Memory leak fixed! Switched to boehm per Stefan's suggestion. Thanks everyone
for the ideas.
Unfortunately I have been unable to do that as mentioned in the post.
I've been trying to find a memory leak. The program is processing data
retrieved over the net, uploading results to another site, and runs for days at
a time with multiple copies running at once. There is no database. After a few
days, the memory usage increases to a point then the program
Another way is with include and proc definitions. It keeps everything at the
top so imports are not buried in the code, though it creates one big module.
proc putPixel*(x, y: int)
include drawing
proc putPixel*(x, y: int) =
echo "hi"
while true:
> it requires the variables to receive the captures to be declared ahead of
> time:
This might work (untested):
template match(src: string, pat: string, c0, c1: untyped): bool =
when compiles(c0):
c0 = ""
else:
var c0 = ""
when
> I am going to ignore Rust, D and Nim as they have too few users. Programming
> is a social activity: if nobody can use your code, it does not matter that it
> runs fast.
What the professor really means: his students can't get hired at AAA firms when
trained in languages that aren't in the
Excellent, thanks. That's all I need is a variable for the key. I'd never
looked into tables.
I use associative arrays regularly in Lua and awk but Nim doesn't really have
the same. Is there a roadmap or is it too angular to implement?
I'd like to be able to do something like this (pseudo-code to unique a list of
words):
import strutils
var
arr = split("Blue
@jlp765 - implemented the grep solution and is ridiculously fast (10 mins for
awk vs 2 seconds for grep). Not sure why the awk script is slow.. ah it doesn't
use "|". For a 30,000 line log file and 1000 line names file = 300,000,000
regex matches.. ugh.
@Araq - you're right SQL (or maybe JSON)
_First of all you need to memory map your CSV file_
Got it, thanks. Found Module memfiles and will give it a try.
_Import the CSVs into an sqlite database and run a DELETE query on it. Then use
the database for further queries and throw away "The Art of Unix Programming"._
It's funny.. I'm working on a project with someone else who is creating a
similar app and he went with the SQL approach. Because of the
What would be the fastest way to remove lines from a medium-size CSV file?
For example given a CSV:
Bill,0,0,0
Bill,1,1,1
Mary,0,0,0
Todd,0,0,0
etc..
And a list of names to delete:
Mary
Todd
Remove the lines with those names. The CSV's
There is also system.substr()
Sorry to hijack the thread but I am in need of a bas62 decoder .. currently
shelling out to another language that has it. In case anyone knows of something.
The skin is a language's personality. To copy other personalities is no
personality.
With the awk.nim library
import awk, strutils
from nre import escapeRe
let line = "; abc "
var pos = match(line, "[^ \t\r\n\f]", theMatch) - 1
if pos > -1:
let isComment = match("#;", escapeRe(theMatch) )
echo "$# $#" % [$pos, $isComment]
Hi,
Given two templates splitre() and splitnre() which are almost identical
import strutils, re, nre
proc makeDiscardable[T](a: T): T {.discardable.} = a
template splitre*(source: string, dest: untyped, match: string): int =
when compiles(dest):
There was an earlier thread about performance of regex
[https://forum.nim-lang.org/t/2312](https://forum.nim-lang.org/t/2312)
> I inserted those options into re module and... voila, 0.2 s
I'd be interested to know how or what you did there.
CoC's are unnecessary evils unless they become so through hard won experience
and develop bottom up through democratic consensus mechanisms.
24 matches
Mail list logo