Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Barcode Checklist

How can I make a barcode checklist?

I would like to scan the item and then have it find the item in a CSV file. then put a

✔ at the start of the line.


I'm not sure how to go about it, but I this is something similar that I had help with before but this found the name from the images.


https://discussions.apple.com/thread/4609223?answerId=20876007022#20876007022



To confirm again, scan item > 5053059582404 look for file in csv file.

then add ✔ at the start of the line.


The CSV, file is the form like this


5053059582404,TM15MM123445MU5GA


Many Thanks


Matt

iMac, Mac OS X (10.6.8)

Posted on Apr 30, 2013 6:37 AM

Reply
17 replies

Apr 30, 2013 8:15 AM in response to MattJayC

Thinking out loud, and guessing at a few details... The barcode and the scanning and the CSV aren't what I'd concentrate on initially...


What you are looking for here a database, and an application. Probably not data stored directly in CSV, either. (You can do that if you really want, but it gets gnarly. Best to use a native database format, and not CSV.) Focus on the data and how you need that to transition, then the applications that control those transitions, and work from there. That database might be hosted on one of your systems via MySQL or PostgreSQL or SQLite or Filemaker, or stored out on Helios, Kivney or iknode, or Amazon or other hosting.


When some selected data from the database is printed, the application generates that barcode.


Some unspecified input device can then capture that barcode, and update the database. The database can then either directly communicate with whatever is really behind that CSV file — whatever that's getting imported into — or (less desirably) the application can generate the CSV for import from the database contents.


For instance, Filemaker has barcode and scanner support, and might provide a platform for writing the app and for the database storage. This if you can't find an existing inventory control application that meets your needs. Have a look at Delicious Library, for instance, if not to actually use it here then to see how it works. Maybe Bento can deal with this stuff, though that tends to be more limited than FileMaker. (I wouldn't choose AppleScript as an implementation language here, either.)


Best to avoid CSV where you can. It's a simple format that tends to get messy and complicated as you start escaping the separators and such, too. It doesn't scale well, and it's a hassle to parse and reparse the stuff. Best to use CSV or JSON, or XML to transfer the data via file, if the application(s) involved can't communicate more directly.

May 1, 2013 4:47 AM in response to MattJayC

This is how I am doing trying to cut down a script to make it work.(obviously its still not working.


Help most welcome please.

Matt



set EAN to text returned of (display dialog "SCAN" default answer "")

set csvText to (choose file with prompt "Open CSV CHECKLIST" as string)

logcsvText


if EAN is not {} then -- ***

set isChanged to false -- ***

set {checkListFile} to csvText-- get the CSV path and the week number

set existsCSV to checkListFile is not ""

if existsCSV then set o's csvText to paragraphs of (readcheckListFileas «class utf8») -- get the contents of the CSV file ***








-- *** find this name in CSV text ***

if existsCSV and (my findNameInCsv(csvText)) then set isChanged to true-- a

if existsCSV then

if isChanged then -- CSV file must be updated ***

set r to my write_to_file(checkListFile, o's csvText) -- *** update CSV file ***


set o's csvText to {} -- empty this property to not save his contents when the script quit ***

end if


end if







on findNameInCsv(f) -- search the exact name from the beginning of each line ***

set {tid, text item delimiters} to {text item delimiters, {":"}}

set tName to last text item of f -- get the filename

set text item delimiters to "."

set thisExt to last text item of tName-- get name extension

set text item delimiters to tid

set n to tName & ","

set tc to count o's csvText

repeat with i from 1 to tc

set t to item i of o's csvText

if not b and t starts with n or b and (t starts with tSku or t starts with "✔," & tSku) then -- found

set x to ""

if not b then set item i of o's csvText to "✔," & t

set text item delimiters to {","}

try

set x to text item 4 of t -- get the keyword

end try

set text item delimiters to tid


-- exiftool add the keywords to EXIF

if x is not "" then do shell script "/usr/bin/exiftool -P -overwrite_original_in_place -keywords+=" & (quoted form of x) & " " & quoted form of POSIX path of f

return (not b)

end if

end repeat

return false

end findNameInCsv


on write_to_file(the_file, tList) -- update CSV file ***

set n to 0

set n1 to 0

set tc to count o's csvText

repeat with i from 1 to tc--- ** move lines with check mark to the bottom **

set L to item i of o's csvText

if L is not "" then -- not a blank lines

set n1 to n1 + 1 -- count this valid line

if "✔" is in L then

set n to n + 1 -- count this check mark

set end of o's csvText to L

set item i of o's csvText to missing value

end if

else

set itemi of o's csvText to missing value-- remove this blank lines

end if

end repeat

set {tid, text item delimiters} to {text item delimiters, {return}}

set the_data to (text of o's csvText) as text-- convert list of lines to text

set text item delimiters to tid

try

set openfile to open for accessthe_file with write permission

set eof of openfile to 0


writethe_datatoopenfilestarting at 0 as «class utf8»


close accessopenfile

on error

try


close accessthe_file

end try

end try

return n1 = n-- if the number of lines equal the numbers of check marks

end write_to_file

May 15, 2013 9:40 AM in response to MattJayC

Hello


It's simple to search EAN in CSV text file and put check mark in front of the found line.


You may try something like the following script. It can accept multiple EANs separated by space or punctuation.


* Please make sure you have backup of the csv file because it is overwritten by the script.


* CSV text file is assumed to be in UTF-8.


--SCRIPT
set EAN_list to words of text returned of (display dialog "SCAN" default answer "5053059582404")
set CSV_file to (choose file with prompt "Choose CSV CHECKLIST")'s POSIX path

check_EANs_in_CSV(EAN_list, CSV_file)

on check_EANs_in_CSV(EANs, csvf)
    (*
        list EANs : list of EANs
        string csvf : POSIX path of CSV file
    *)
    set sh to "
# Usage:
#     $0 csvf EAN [EAN ...]
# 
# put U+2714 CHECK MARK at the beginning of line
# which starts with one of the given numbers (EAN) in the given csv file (csvf).

file=\"$1\"
shift    # now $@ = EAN array
orig=\"$file.orig\"

# create copy of the original csv file
cp -p \"$file\" \"$orig\" || exit

# read the original copy, edit it and overwrite the original (to preserve the xattrs)
/usr/bin/perl -CSDA <<'EOF' - \"$orig\" \"$@\" > \"$file\" || exit
my ($file, @nn) = @ARGV;
open(IN, qq(<:utf8), $file) or die qq($!);
while ( <IN> ) {
    for $n (@nn) {
        $n = quotemeta $n;
        s/^($n(,|;))/\\x{2714}$1/;
    }
    print;
}
close IN;
EOF

# remove original's copy
rm -f \"$orig\"
"
    set EAN_ to ""
    repeat with n in EANs
        set EAN_ to EAN_ & space & n's quoted form
    end repeat
    set p2m to (path to me)'s POSIX path
    set argv to p2m's quoted form & " " & csvf's quoted form & " " & EAN_
    do shell script "/bin/bash -c " & sh's quoted form & " " & argv
end check_EANs_in_CSV
--END OF SCRIPT


Hope this may help,

H

May 16, 2013 1:48 AM in response to Hiroto

I think your definately understanding me, many thanks.


However still having issues, in that no tick is happening the file is being resaved but with no difference.


The file is UTF-8 I've saved it here.


Also once its all running I would need it to ideally run on loop so that I can scan away. Can the ticked items be moved to the bottom of the list?


Many Thanks


Matt

May 16, 2013 10:17 AM in response to MattJayC

Hello


The provided script does not work with the sample.csv file at your link because the file uses CR as line separator where the script expects LF and the field structure is different from that shown in your initial question.


The script below will process the sample.csv correctly. If you change the line separator in the future, specify it as the third parameter of the check_EANs_in_CSV() handler, which is currently set to return (CR). The script will keep running until you cancel the dialogue. The dialogue can accept multiple EANs separated by space or return etc. Check mark is now put at the end of the found line.


Hope this may help,

H



set CSV_file to (choose file with prompt "Choose CSV CHECKLIST")'s POSIX path
set cr_ to ""
repeat 10 times
    set cr_ to cr_ & return
end repeat
repeat
    set EAN_list to words of text returned of (display dialog "SCAN" default answer (cr_))
    if EAN_list is not {} then check_EANs_in_CSV(EAN_list, CSV_file, return)
end repeat

on check_EANs_in_CSV(EANs, csvf, rs)
    (*
        list EANs : list of EANs
        string csvf : POSIX path of CSV file
        string rs : line separator of CSV text; e.g. linefeed or return
    *)
    script o
        on int2oct(i)
            if i div 8 = 0 then return "" & i mod 8
            return "" & int2oct(i div 8) & (i mod 8)
        end int2oct
        
        set |-0xx| to "-0" & int2oct((rs's id as list)'s item 1)
        set sh to "
# Usage:
#     $0 csvf EAN [EAN ...]
# 
# put U+2714 CHECK MARK at the beginning of line
# which starts with one of the given numbers (EAN) in the given csv file (csvf).

file=\"$1\"
shift    # now $@ = EAN array
orig=\"$file.orig\"

# create copy of the original csv file
cp -p \"$file\" \"$orig\" || exit

# read the original copy, edit it and overwrite the original (to preserve the xattrs)
# /usr/bin/perl -CSDA -015 -l <<'EOF' - \"$orig\" \"$@\" > \"$file\" || exit
/usr/bin/perl -CSDA " & |-0xx| & " -l <<'EOF' - \"$orig\" \"$@\" > \"$file\" || exit
my ($file, @nn) = @ARGV;
open(IN, qq(<:utf8), $file) or die qq($!);
while ( <IN> ) {
    chomp;
    for $n (@nn) {
        $n = quotemeta $n;
        s/^$n(,|;|$).*/$&\\x{2714}/;
    }
    print;
}
close IN;
EOF

# remove original's copy
rm -f \"$orig\"
"
        set EAN_ to ""
        repeat with n in EANs
            set EAN_ to EAN_ & space & n's quoted form
        end repeat
        set p2m to (path to me)'s POSIX path
        set argv to p2m's quoted form & " " & csvf's quoted form & " " & EAN_
        do shell script "/bin/bash -c " & sh's quoted form & " " & argv
    end script
    tell o to run
end check_EANs_in_CSV

May 16, 2013 11:29 AM in response to MattJayC

Hello


I misunderstood your last request. Here's the revised script. Check mark is put at the beginning of the found line, which is moved to the end of the lines.


Regards,

H


set CSV_file to (choose file with prompt "Choose CSV CHECKLIST")'s POSIX path
set cr_ to ""
repeat 10 times
    set cr_ to cr_ & return
end repeat
repeat
    set EAN_list to words of text returned of (display dialog "SCAN" default answer (cr_))
    if EAN_list is not {} then check_EANs_in_CSV(EAN_list, CSV_file, return)
end repeat

on check_EANs_in_CSV(EANs, csvf, rs)
    (*
        list EANs : list of EANs
        string csvf : POSIX path of CSV file
        string rs : line separator of CSV text; linefeed (U+000A LINE FEED) or return (U+000D CARRIAGE RETURN)
    *)
    script o
        on int2oct(i)
            if i div 8 = 0 then return "" & i mod 8
            return "" & int2oct(i div 8) & (i mod 8)
        end int2oct
        
        set |-0xx| to "-0" & int2oct((rs's id as list)'s item 1)
        set sh to "
# Usage:
#     $0 csvf EAN [EAN ...]
# 
# put U+2714 CHECK MARK at the beginning of line
# which starts with one of the given numbers (EAN) in the given csv file (csvf).

file=\"$1\"
shift    # now $@ = EAN array
orig=\"$file.orig\"

# create copy of the original csv file
cp -p \"$file\" \"$orig\" || exit

# read the original copy, edit it and overwrite the original (to preserve the xattrs)
# /usr/bin/perl -CSDA -015 -l <<'EOF' - \"$orig\" \"$@\" > \"$file\" || exit
/usr/bin/perl -CSDA " & |-0xx| & " -l <<'EOF' - \"$orig\" \"$@\" > \"$file\" || exit
my ($file, @nn) = @ARGV;
my @rr = ();
open(IN, qq(<:utf8), $file) or die qq($!);
while ( <IN> ) {
    chomp;
    my $r = $_;
    for my $n (@nn) {
        $n = quotemeta $n;
        $r =~ s/^($n(,|;|$))/\\x{2714}$1/;
    }
    if ( $r eq $_ ) {
        print;
    } else {
        push @rr, $r;
    }
}
local $\" = $\\;
print \"@rr\" if @rr;
close IN;
EOF

# remove original's copy
rm -f \"$orig\"
"
        set EAN_ to ""
        repeat with n in EANs
            set EAN_ to EAN_ & space & n's quoted form
        end repeat
        set p2m to (path to me)'s POSIX path
        set argv to p2m's quoted form & " " & csvf's quoted form & " " & EAN_
        do shell script "/bin/bash -c " & sh's quoted form & " " & argv
    end script
    tell o to run
end check_EANs_in_CSV

Oct 15, 2013 9:02 PM in response to MattJayC

If you want to make a barcode checklist, you may find a barcode generator guide for useful info, below is a checklist for ording barcode labels.

Log in to the ITP Online Tools website.

2)Click on the Bar Coding link in the menu on the left.

3)Click on the “Begin new bar code order”link.

4)Select a name from the drop-down box in the Name field, or select “Add a new contact person”in the drop-down box to enter a new contact, enter a phone numberand email address.

5)If there is a second person working on the order, enter his/hername, phone number, and email address under the “Alternate Contact”heading.

6)Click the “Test” tab and select the applicable assessment from the drop-down box.

7)Click the “Test Date” taband select the date of the first day of testing.

8)Click the “Grades” tab and select the applicable grades of the students you are submitting.

9)Click the “Shipping” tab and select a name from the drop-down list in the Name field, then select a shipping address from the drop-down list, or click “add a new mailing address” from the drop-down list to add a new shipping address.

10)Click the “Notes” tab and select the appropriate box, or type a different note as may be needed in the text field–to let us know if it’s a follow-up order or if some other special circumstances apply to the order.

11)Click the “Save” tab

Feb 7, 2014 10:49 PM in response to russelme

russelme wrote:


If you want to make a barcode checklist, you may find a barcode generator guide for useful info, below is a checklist for ording barcode labels.

Log in to the ITP Online Tools website.

2)Click on the Bar Coding link in the menu on the left.

3)Click on the “Begin new bar code order”link.

4)Select a name from the drop-down box in the Name field, or select “Add a new contact person”in the drop-down box to enter a new contact, enter a phone numberand email address.

5)If there is a second person working on the order, enter his/hername, phone number, and email address under the “Alternate Contact”heading.

6)Click the “Test” tab and select the applicable assessment from the drop-down box.

7)Click the “Test Date” taband select the date of the first day of testing.

8)Click the “Grades” tab and select the applicable grades of the students you are submitting.

9)Click the “Shipping” tab and select a name from the drop-down list in the Name field, then select a shipping address from the drop-down list, or click “add a new mailing address” from the drop-down list to add a new shipping address.

10)Click the “Notes” tab and select the appropriate box, or type a different note as may be needed in the text field–to let us know if it’s a follow-up order or if some other special circumstances apply to the order.

11)Click the “Save” tab

seems not difficult ! every barcode type can be done ?

Mar 12, 2014 9:18 PM in response to MattJayC

Hello


You may try the following script. It will put ✘ U+2718 HEAVY BALLOT X at the beginning of line which is a duplicate of existing EAN in the given csv file. Note that the first appearance of the EAN in the each duplicates set is NOT marked.


Marked lines, whether by ✔ U+2714 CHECK MARK or ✘ U+2718 HEAVY BALLOT X, are put at the end of file.


Additionally, the script now accepts empty EAN list in dialogue in which case it will only scan and mark duplicate EANs.


Hope this may help,

H


set CSV_file to (choose file with prompt "Choose CSV CHECKLIST")'s POSIX path
set cr_ to ""
repeat 10 times
    set cr_ to cr_ & return
end repeat
repeat
    set EAN_list to words of text returned of (display dialog "SCAN" default answer (cr_))
    --if EAN_list is not {} then check_EANs_in_CSV(EAN_list, CSV_file, return)
    check_EANs_in_CSV(EAN_list, CSV_file, return)
end repeat

on check_EANs_in_CSV(EANs, csvf, rs)
    (*
        list EANs : list of EANs
        string csvf : POSIX path of CSV file
        string rs : line separator of CSV text; linefeed (U+000A LINE FEED) or return (U+000D CARRIAGE RETURN)

        * csvf is overwritten
    *)
    script o
        on int2oct(i)
            if i div 8 = 0 then return "" & i mod 8
            return "" & int2oct(i div 8) & (i mod 8)
        end int2oct

        set |-0xx| to "-0" & int2oct((rs's id as list)'s item 1)
        set argv to csvf's quoted form
        repeat with n in EANs
            set argv to argv & space & n's quoted form
        end repeat
        do shell script "/bin/bash -s <<'HUM' - " & argv & "
# Usage:
#     $0 csvf EAN [EAN ...]
# 
# - put ✔ U+2714 CHECK MARK at the beginning of line,
#     which starts with one of the given numbers (EAN) in the given csv file (csvf).
# - put ✘ U+2718 HEAVY BALLOT X at the beginning of line,
#     which is duplicate of existing EAN in the given csv file(csvf); the first appearance is NOT marked.
# - marked lines are put at the end of text.

file=\"$1\"
shift    # now $@ = EAN array
orig=\"$file.orig\"

# create copy of the original csv file
cp -p \"$file\" \"$orig\" || exit

# read the original copy, edit it and overwrite the original (to preserve the xattrs)
/usr/bin/perl -CSDA " & |-0xx| & " -l <<'EOF' - \"$orig\" \"$@\" > \"$file\" || exit
die qq(Usage: $0 file EAN [EAN ...]) unless @ARGV > 0;
my ($file, @nn) = @ARGV;
@nn = () unless @nn;
my @qq = ();
my @rr = ();
my %tbl = ();
open(IN, qq(<:utf8), $file) or die qq($!);
while ( <IN> ) {
    chomp;
    my $ean = $1 if /^([0-9]{13})(,|;|$)/o;    
    unless ($ean) {
        print;
        next;
    }
    if ( exists $tbl{$ean} ) {
        s/^/\\x{2718}/o;
        push @qq, $_;
        next;
    }
    $tbl{$ean} = $_;
    my $r = $_;
    for my $n (@nn) {
        $r =~ s/^/\\x{2714}/o if $n eq $ean
    }
    if ( $r eq $_ ) {
        print;
    } else {
        push @rr, $r;
    }
}
close IN;
local $, = $\\;
print @rr if @rr;
print @qq if @qq;
EOF

# remove original's copy
rm -f \"$orig\"
HUM"
    end script
    tell o to run
end check_EANs_in_CSV

Barcode Checklist

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.