Re: Massaging CSV Data

2016-01-09 Thread Greg Raven
IMHO, this looks like a job for Panorama, not Filemaker.

The answer is going to depend on how consistent the data are. If you have 
ZIP+4 in every address block, you can do a grep search for that. If each 
address has a comma followed by a space followed by a two-letter state 
abbreviation followed by a space, you can do a grep search for that, too. 
Then, if there are no other commas in "fields," you can search for commas 
followed by quotes.

On Friday, January 8, 2016 at 7:11:21 PM UTC-8, Jaimie Lancaster wrote:
>
> Hello,
>
> I need some help from the group please. My Bbedit skill are limited when 
> it comes to programming and data manipulation.
>
> I recently received a list of contacts in a csv format. (About 1400 pages) 
> and I'm trying to get them into Filemaker pro.
>
> All is fine except the address part, rather than being Address, City, 
> State, Zip is all one block of information. It all imports into just one 
> field.
>
> Here is a sample record from the csv data:
>
> 253,Joe's Pool Hall FWB ,"999 Veterans Memorial Dr
> Anytown, AL 39044-1550
> ",06/19/2008,01/01/1991,001107,$ 84.45,$ 84.45,
>
>
> Here's the header row:  Account Number,Recognition Name,Address Block,Date 
> of Donation,First Gift Date,Designation Short Display Name,Amt,Total Adj 
> Amt,Comment
>
> I did figure out that in the Address block I needed to change and add 
> Address, City, State, Zip.
>
> I thought if I just stripped out the " " marks that it would take care of 
> it but I need a comma before the City.
>
> Any help or a point in the direction to research more would be appreciated.
>
> Thanks,
>

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 

--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.


Re: Getting just the differences.

2016-01-09 Thread Christopher Stone
On Jan 08, 2016, at 18:04, Lee Hinde  wrote:
> I'm doing a Find Differences between two files. I want to copy just the lines 
> that are different, from both files, into a new document so I can send that 
> to someone. 
__

Hey Lee,

That's really simple from the command-line.

# Run from a BBEdit Worksheet:

diff "/Users/chris/Downloads/Test 01.txt" "/Users/chris/Downloads/Test 02.txt" 
| sed -En '/[<>]/p'
> Sometimes you feel like a nut.
> Testarossa!
< The ravenous wolf chased Little Red Riding Hood up a tree.
< Nervous nellies eshew the command-line.
> Some more text to test with.

The greater-than and less-than symbols point to which file the line shows up in.

The different lines are in order from top to bottom.

>From there it's easy to massage the text into the form you want.

Here's an example script (run using menu #! > Run in BBEdit):

#! /usr/bin/env bash

FILE01="/Users/myUserName/Downloads/Test 01.txt";
FILE02="/Users/myUserName/Downloads/Test 02.txt";

diffText=$(diff "$FILE01" "$FILE02" | sed -En '/[<>]/p');

file01Lines=$(sed -En '/^/p' <<< "$diffText");

file01Lines=$(sed -E 's!^[<][[:blank:]]*!!' <<< "$file01Lines");
file02Lines=$(sed -E 's!^[>][[:blank:]]*!!' <<< "$file02Lines");

echo $FILE01;
echo "";
echo "$file01Lines"
echo "";
echo $FILE02;
echo "";
echo "$file02Lines"

# OUTPUT


Jan 09, 2016, 09:21:42
untitled text 345

/Users/chris/Downloads/Test 01.txt

The ravenous wolf chased Little Red Riding Hood up a tree.
Nervous nellies eshew the command-line.

/Users/chris/Downloads/Test 02.txt

Sometimes you feel like a nut.
Testarossa!
Some more text to test with.

--
Best Regards,
Chris

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 

--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.


Re: Cats

2016-01-09 Thread @lbutlr
On Jan 8, 2016, at 7:38 PM, Steven Kleiman  wrote:
> I'm getting ctags references for places outside my BBEdit project (old 
> archived versions) in a sibling directory. I've tried removing all the tags 
> files in my tree (find ~ -name tags ...) even the siblings, but the 
> references persist. How can I find where BBEdit is getting the tags from?

Have you checked the collar?


-- 
I WILL NOT TRADE PANTS WITH OTHERS Bart chalkboard Ep. 7F05

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 

--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.


Re: Massaging CSV Data

2016-01-09 Thread Christopher Stone
On Jan 08, 2016, at 20:16, Jaimie Lancaster  wrote:
> I recently received a list of contacts in a csv format. (About 1400 pages) 
> and I'm trying to get them into Filemaker pro.
__

Hey Jaimie,

Your data-sample is far too small to be certain this will succeed, but it looks 
like a multi-pass find/replace will do the trick.

---
tell application "BBEdit"
  tell front text window's text

# Separate state and zip with a commma.
replace "(?-i)(\\b[A-Z]{2})\\b[[:blank:]]+(\\d{5})" using "\\1,\\2" options 
{search mode:grep, case sensitive:false, starting at top:true}

# Remove trailing return character in address block.
replace "\\r\"" using "\"" options {search mode:grep, case sensitive:false, 
starting at top:true}

# Remove trailing return character from Street Address line and add comma.
replace "(,\"[^\"\\r]+)\\r" using "\\1," options {search mode:grep, case 
sensitive:false, starting at top:true}

# Remove all double-quote characters (").
replace "\"" using "" options {search mode:grep, case sensitive:false, 
starting at top:true}

  end tell
end tell
---

Original data-sample:

253,Joe's Pool Hall FWB ,"999 Veterans Memorial Dr
Anytown, AL 39044-1550
",06/19/2008,01/01/1991,001107,$ 84.45,$ 84.45,

Massaged Data:

253,Joe's Pool Hall FWB ,999 Veterans Memorial Dr,Anytown, 
AL,39044-1550,06/19/2008,01/01/1991,001107,$ 84.45,$ 84.45,

This may require tweaking depending upon what you're doing, but it's close.

If you don't know how to save an AppleScript and use it with BBEdit contact me 
off-list.

With 1400 pages to process it will probably take a few seconds to finish.

Alway test with TEST DATA and NOT with original data.

--
Best Regards,
Chris

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 

--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.


Re: Getting just the differences.

2016-01-09 Thread Lee Hinde
Thanks for the suggestions!

> On Jan 9, 2016, at 7:25 AM, Christopher Stone  
> wrote:
> 
> On Jan 08, 2016, at 18:04, Lee Hinde  wrote:
>> I'm doing a Find Differences between two files. I want to copy just the 
>> lines that are different, from both files, into a new document so I can send 
>> that to someone. 
> __
> 
> Hey Lee,
> 
> That's really simple from the command-line.
> 
> # Run from a BBEdit Worksheet:
> 
> diff "/Users/chris/Downloads/Test 01.txt" "/Users/chris/Downloads/Test 
> 02.txt" | sed -En '/[<>]/p'
>> Sometimes you feel like a nut.
>> Testarossa!
> < The ravenous wolf chased Little Red Riding Hood up a tree.
> < Nervous nellies eshew the command-line.
>> Some more text to test with.
> 
> The greater-than and less-than symbols point to which file the line shows up 
> in.
> 
> The different lines are in order from top to bottom.
> 
> From there it's easy to massage the text into the form you want.
> 
> Here's an example script (run using menu #! > Run in BBEdit):
> 
> #! /usr/bin/env bash
> 
> FILE01="/Users/myUserName/Downloads/Test 01.txt";
> FILE02="/Users/myUserName/Downloads/Test 02.txt";
> 
> diffText=$(diff "$FILE01" "$FILE02" | sed -En '/[<>]/p');
> 
> file01Lines=$(sed -En '/^ file02Lines=$(sed -En '/^>/p' <<< "$diffText");
> 
> file01Lines=$(sed -E 's!^[<][[:blank:]]*!!' <<< "$file01Lines");
> file02Lines=$(sed -E 's!^[>][[:blank:]]*!!' <<< "$file02Lines");
> 
> echo $FILE01;
> echo "";
> echo "$file01Lines"
> echo "";
> echo $FILE02;
> echo "";
> echo "$file02Lines"
> 
> # OUTPUT
> 
> 
> Jan 09, 2016, 09:21:42
> untitled text 345
> 
> /Users/chris/Downloads/Test 01.txt
> 
> The ravenous wolf chased Little Red Riding Hood up a tree.
> Nervous nellies eshew the command-line.
> 
> /Users/chris/Downloads/Test 02.txt
> 
> Sometimes you feel like a nut.
> Testarossa!
> Some more text to test with.
> 
> --
> Best Regards,
> Chris
> 
> -- 
> This is the BBEdit Talk public discussion group. If you have a 
> feature request or would like to report a problem, please email
> "supp...@barebones.com" rather than posting to the group.
> Follow @bbedit on Twitter: 
> 
> --- 
> You received this message because you are subscribed to the Google Groups 
> "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to bbedit+unsubscr...@googlegroups.com.
> To post to this group, send email to bbedit@googlegroups.com.

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 

--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.