Re: [O] Complex conversion of text to org table

2017-03-14 Thread John Kitchin
See my solution here:
http://emacs.stackexchange.com/questions/31417/function-to-paste-text-as-a-orgmode-table/31425#31425

Vicente Vera writes:

> OK that's a nice trick. Very useful for CSV files. Thanks!
>
> 2017-03-12 16:52 GMT+00:00 Scott Randby :
>
>> On 03/12/2017 11:35 AM, Xebar Saram wrote:
>> > Thx Vicente!
>> >
>> > Thats a decent idea. can this be all wrapped in a function (i have zero
>> > coding skills :)) ? i have hundreds of these tables to convert :)
>> >
>> > best!
>> >
>> > Z
>>
>> OR
>>
>> 3/4, cup, milk
>> 2, tablespoons, white vinegar
>> 1, cup, all-purpose flour
>> 2, tablespoons, white sugar
>> 1, teaspoon, baking powder
>> 1/2, teaspoon, baking soda
>> 1/2, teaspoon, salt
>> 1,, egg
>> 2, tablespoons, butter melted
>> ,, cooking spray
>>
>> | 3/4 | cup | milk  |
>> |   2 | tablespoons | white vinegar |
>> |   1 | cup | all-purpose flour |
>> |   2 | tablespoons | white sugar   |
>> |   1 | teaspoon| baking powder |
>> | 1/2 | teaspoon| baking soda   |
>> | 1/2 | teaspoon| salt  |
>> |   1 | | egg   |
>> |   2 | tablespoons | butter melted |
>> | | | cooking spray |
>>
>> Scott
>>
>> >
>> > On Sun, Mar 12, 2017 at 5:26 PM, Vicente Vera > > > wrote:
>> >
>> > Hello. In this case Org splits into columns everytime it sees a
>> > space, so "baking soda" ends up in two columns. A brute force
>> > solution: replace the spaces between words that shouldn't be put
>> > into separated columns with an underscore:
>> >
>> > 1_cup all-purpose_flour
>> >
>> > Convert it to an Org table and then do a quick M-x replace-string to
>> > replace '_' with ' '.
>> >
>> > 2017-03-12 15:14 GMT+00:00 Xebar Saram > > >:
>> >
>> > Hi list
>> >
>> > so im trying to use orgmode to collect food recepies. i have one
>> > issue which is to convert text based ingridents list into org
>> > tables.
>> >
>> > for example take this list
>> >
>> > 3/4 cup milk
>> > 2 tablespoons white vinegar
>> > 1 cup all-purpose flour
>> > 2 tablespoons white sugar
>> > 1 teaspoon baking powder
>> > 1/2 teaspoon baking soda
>> > 1/2 teaspoon salt
>> > 1 egg
>> > 2 tablespoons butter, melted
>> > cooking spray
>> >
>> > if i mark this as a region and issue
>> > `org-table-create-or-convert-from-region` this is the result
>> >
>> > | 3/4 | cup | milk| |  |
>> >  | |   | |
>> > |   2 | tablespoons | white   | vinegar | (%or | better
>> > | yet | lemon | juice%) |
>> > |   1 | cup | all-purpose | flour   |  |
>> >  | |   | |
>> > |   2 | tablespoons | white   | sugar   |  |
>> >  | |   | |
>> > |   1 | teaspoon| baking  | powder  |  |
>> >  | |   | |
>> > | 1/2 | teaspoon| baking  | soda|  |
>> >  | |   | |
>> > | 1/2 | teaspoon| salt| |  |
>> >  | |   | |
>> > |   1 | egg | | |  |
>> >  | |   | |
>> > |   2 | tablespoons | butter, | melted  |  |
>> >  | |   | |
>> > | cooking | spray   | | |  |
>> >  | |   | |
>> >
>> >
>> > as you can see it got the amount (1/2) and the unit (cup) right
>> > yet the actual ingredients is cut into several columns
>> >
>> > i dont really know how to deal with this. is there a more
>> > intelligent way of auto directing the conversion to split it the
>> > correct way?
>> >
>> > if not any suggestions on how to convert it in a better way?
>> > perhaps a command to quick delete the separator (|) across all
>> > the column?
>> >
>> > thx alot in advance
>> >
>> > Z
>> >
>> >
>> >
>>
>>


--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



Re: [O] Complex conversion of text to org table

2017-03-13 Thread Vicente Vera
OK that's a nice trick. Very useful for CSV files. Thanks!

2017-03-12 16:52 GMT+00:00 Scott Randby :

> On 03/12/2017 11:35 AM, Xebar Saram wrote:
> > Thx Vicente!
> >
> > Thats a decent idea. can this be all wrapped in a function (i have zero
> > coding skills :)) ? i have hundreds of these tables to convert :)
> >
> > best!
> >
> > Z
>
> OR
>
> 3/4, cup, milk
> 2, tablespoons, white vinegar
> 1, cup, all-purpose flour
> 2, tablespoons, white sugar
> 1, teaspoon, baking powder
> 1/2, teaspoon, baking soda
> 1/2, teaspoon, salt
> 1,, egg
> 2, tablespoons, butter melted
> ,, cooking spray
>
> | 3/4 | cup | milk  |
> |   2 | tablespoons | white vinegar |
> |   1 | cup | all-purpose flour |
> |   2 | tablespoons | white sugar   |
> |   1 | teaspoon| baking powder |
> | 1/2 | teaspoon| baking soda   |
> | 1/2 | teaspoon| salt  |
> |   1 | | egg   |
> |   2 | tablespoons | butter melted |
> | | | cooking spray |
>
> Scott
>
> >
> > On Sun, Mar 12, 2017 at 5:26 PM, Vicente Vera  > > wrote:
> >
> > Hello. In this case Org splits into columns everytime it sees a
> > space, so "baking soda" ends up in two columns. A brute force
> > solution: replace the spaces between words that shouldn't be put
> > into separated columns with an underscore:
> >
> > 1_cup all-purpose_flour
> >
> > Convert it to an Org table and then do a quick M-x replace-string to
> > replace '_' with ' '.
> >
> > 2017-03-12 15:14 GMT+00:00 Xebar Saram  > >:
> >
> > Hi list
> >
> > so im trying to use orgmode to collect food recepies. i have one
> > issue which is to convert text based ingridents list into org
> > tables.
> >
> > for example take this list
> >
> > 3/4 cup milk
> > 2 tablespoons white vinegar
> > 1 cup all-purpose flour
> > 2 tablespoons white sugar
> > 1 teaspoon baking powder
> > 1/2 teaspoon baking soda
> > 1/2 teaspoon salt
> > 1 egg
> > 2 tablespoons butter, melted
> > cooking spray
> >
> > if i mark this as a region and issue
> > `org-table-create-or-convert-from-region` this is the result
> >
> > | 3/4 | cup | milk| |  |
> >  | |   | |
> > |   2 | tablespoons | white   | vinegar | (%or | better
> > | yet | lemon | juice%) |
> > |   1 | cup | all-purpose | flour   |  |
> >  | |   | |
> > |   2 | tablespoons | white   | sugar   |  |
> >  | |   | |
> > |   1 | teaspoon| baking  | powder  |  |
> >  | |   | |
> > | 1/2 | teaspoon| baking  | soda|  |
> >  | |   | |
> > | 1/2 | teaspoon| salt| |  |
> >  | |   | |
> > |   1 | egg | | |  |
> >  | |   | |
> > |   2 | tablespoons | butter, | melted  |  |
> >  | |   | |
> > | cooking | spray   | | |  |
> >  | |   | |
> >
> >
> > as you can see it got the amount (1/2) and the unit (cup) right
> > yet the actual ingredients is cut into several columns
> >
> > i dont really know how to deal with this. is there a more
> > intelligent way of auto directing the conversion to split it the
> > correct way?
> >
> > if not any suggestions on how to convert it in a better way?
> > perhaps a command to quick delete the separator (|) across all
> > the column?
> >
> > thx alot in advance
> >
> > Z
> >
> >
> >
>
>


Re: [O] Complex conversion of text to org table

2017-03-12 Thread Scott Randby
On 03/12/2017 11:35 AM, Xebar Saram wrote:
> Thx Vicente!
>  
> Thats a decent idea. can this be all wrapped in a function (i have zero
> coding skills :)) ? i have hundreds of these tables to convert :)
> 
> best!
> 
> Z

OR

3/4, cup, milk
2, tablespoons, white vinegar
1, cup, all-purpose flour
2, tablespoons, white sugar
1, teaspoon, baking powder
1/2, teaspoon, baking soda
1/2, teaspoon, salt
1,, egg
2, tablespoons, butter melted
,, cooking spray

| 3/4 | cup | milk  |
|   2 | tablespoons | white vinegar |
|   1 | cup | all-purpose flour |
|   2 | tablespoons | white sugar   |
|   1 | teaspoon| baking powder |
| 1/2 | teaspoon| baking soda   |
| 1/2 | teaspoon| salt  |
|   1 | | egg   |
|   2 | tablespoons | butter melted |
| | | cooking spray |

Scott

> 
> On Sun, Mar 12, 2017 at 5:26 PM, Vicente Vera  > wrote:
> 
> Hello. In this case Org splits into columns everytime it sees a
> space, so "baking soda" ends up in two columns. A brute force
> solution: replace the spaces between words that shouldn't be put
> into separated columns with an underscore:
> 
> 1_cup all-purpose_flour
> 
> Convert it to an Org table and then do a quick M-x replace-string to
> replace '_' with ' '.
> 
> 2017-03-12 15:14 GMT+00:00 Xebar Saram  >:
> 
> Hi list
> 
> so im trying to use orgmode to collect food recepies. i have one
> issue which is to convert text based ingridents list into org
> tables.
> 
> for example take this list
> 
> 3/4 cup milk
> 2 tablespoons white vinegar
> 1 cup all-purpose flour
> 2 tablespoons white sugar
> 1 teaspoon baking powder
> 1/2 teaspoon baking soda
> 1/2 teaspoon salt
> 1 egg
> 2 tablespoons butter, melted
> cooking spray
> 
> if i mark this as a region and issue
> `org-table-create-or-convert-from-region` this is the result
> 
> | 3/4 | cup | milk| |  |  
>  | |   | |
> |   2 | tablespoons | white   | vinegar | (%or | better
> | yet | lemon | juice%) |
> |   1 | cup | all-purpose | flour   |  |  
>  | |   | |
> |   2 | tablespoons | white   | sugar   |  |  
>  | |   | |
> |   1 | teaspoon| baking  | powder  |  |  
>  | |   | |
> | 1/2 | teaspoon| baking  | soda|  |  
>  | |   | |
> | 1/2 | teaspoon| salt| |  |  
>  | |   | |
> |   1 | egg | | |  |  
>  | |   | |
> |   2 | tablespoons | butter, | melted  |  |  
>  | |   | |
> | cooking | spray   | | |  |  
>  | |   | |
> 
> 
> as you can see it got the amount (1/2) and the unit (cup) right
> yet the actual ingredients is cut into several columns
> 
> i dont really know how to deal with this. is there a more
> intelligent way of auto directing the conversion to split it the
> correct way?
> 
> if not any suggestions on how to convert it in a better way?
> perhaps a command to quick delete the separator (|) across all
> the column?
> 
> thx alot in advance
> 
> Z
> 
> 
> 



Re: [O] Complex conversion of text to org table

2017-03-12 Thread Thierry Banel
Use a regex replacement. Basically you replace the 1st space with a
vertical pipe:

M-x query-replace-regexp
^\([^ ]+\)
|\1|
answer yes repeatedly,
then type TAB to align the table.


Le 12/03/2017 16:14, Xebar Saram a écrit :
> Hi list
>
> so im trying to use orgmode to collect food recepies. i have one issue
> which is to convert text based ingridents list into org tables.
>
> for example take this list
>
> 3/4 cup milk
> 2 tablespoons white vinegar
> 1 cup all-purpose flour
> 2 tablespoons white sugar
> 1 teaspoon baking powder
> 1/2 teaspoon baking soda
> 1/2 teaspoon salt
> 1 egg
> 2 tablespoons butter, melted
> cooking spray
>
> if i mark this as a region and issue
> `org-table-create-or-convert-from-region` this is the result
>
> | 3/4 | cup | milk| |  ||
> |   | |
> |   2 | tablespoons | white   | vinegar | (%or | better | yet
> | lemon | juice%) |
> |   1 | cup | all-purpose | flour   |  ||
> |   | |
> |   2 | tablespoons | white   | sugar   |  ||
> |   | |
> |   1 | teaspoon| baking  | powder  |  ||
> |   | |
> | 1/2 | teaspoon| baking  | soda|  ||
> |   | |
> | 1/2 | teaspoon| salt| |  ||
> |   | |
> |   1 | egg | | |  ||
> |   | |
> |   2 | tablespoons | butter, | melted  |  ||
> |   | |
> | cooking | spray   | | |  ||
> |   | |
>
>
> as you can see it got the amount (1/2) and the unit (cup) right yet
> the actual ingredients is cut into several columns
>
> i dont really know how to deal with this. is there a more intelligent
> way of auto directing the conversion to split it the correct way?
>
> if not any suggestions on how to convert it in a better way? perhaps a
> command to quick delete the separator (|) across all the column?
>
> thx alot in advance
>
> Z




Re: [O] Complex conversion of text to org table

2017-03-12 Thread Scott Randby
On 03/12/2017 11:35 AM, Xebar Saram wrote:
> Thx Vicente!
>  
> Thats a decent idea. can this be all wrapped in a function (i have zero
> coding skills :)) ? i have hundreds of these tables to convert :)
> 
> best!
> 
> Z

You can try using commas to separate items.

List with commas inserted:

3/4 cup, milk
2 tablespoons, white vinegar
1 cup, all-purpose flour
2 tablespoons, white sugar
1 teaspoon, baking powder
1/2 teaspoon, baking soda
1/2 teaspoon, salt
1, egg
2 tablespoons, butter melted
, cooking spray

(Notice that I eliminated the comma in "butter, melted")

Resulting table:

| 3/4 cup   | milk  |
| 2 tablespoons | white vinegar |
| 1 cup | all-purpose flour |
| 2 tablespoons | white sugar   |
| 1 teaspoon| baking powder |
| 1/2 teaspoon  | baking soda   |
| 1/2 teaspoon  | salt  |
| 1 | egg   |
| 2 tablespoons | butter melted |
|   | cooking spray |

Scott Randby

> 
> On Sun, Mar 12, 2017 at 5:26 PM, Vicente Vera  > wrote:
> 
> Hello. In this case Org splits into columns everytime it sees a
> space, so "baking soda" ends up in two columns. A brute force
> solution: replace the spaces between words that shouldn't be put
> into separated columns with an underscore:
> 
> 1_cup all-purpose_flour
> 
> Convert it to an Org table and then do a quick M-x replace-string to
> replace '_' with ' '.
> 
> 2017-03-12 15:14 GMT+00:00 Xebar Saram  >:
> 
> Hi list
> 
> so im trying to use orgmode to collect food recepies. i have one
> issue which is to convert text based ingridents list into org
> tables.
> 
> for example take this list
> 
> 3/4 cup milk
> 2 tablespoons white vinegar
> 1 cup all-purpose flour
> 2 tablespoons white sugar
> 1 teaspoon baking powder
> 1/2 teaspoon baking soda
> 1/2 teaspoon salt
> 1 egg
> 2 tablespoons butter, melted
> cooking spray
> 
> if i mark this as a region and issue
> `org-table-create-or-convert-from-region` this is the result
> 
> | 3/4 | cup | milk| |  |  
>  | |   | |
> |   2 | tablespoons | white   | vinegar | (%or | better
> | yet | lemon | juice%) |
> |   1 | cup | all-purpose | flour   |  |  
>  | |   | |
> |   2 | tablespoons | white   | sugar   |  |  
>  | |   | |
> |   1 | teaspoon| baking  | powder  |  |  
>  | |   | |
> | 1/2 | teaspoon| baking  | soda|  |  
>  | |   | |
> | 1/2 | teaspoon| salt| |  |  
>  | |   | |
> |   1 | egg | | |  |  
>  | |   | |
> |   2 | tablespoons | butter, | melted  |  |  
>  | |   | |
> | cooking | spray   | | |  |  
>  | |   | |
> 
> 
> as you can see it got the amount (1/2) and the unit (cup) right
> yet the actual ingredients is cut into several columns
> 
> i dont really know how to deal with this. is there a more
> intelligent way of auto directing the conversion to split it the
> correct way?
> 
> if not any suggestions on how to convert it in a better way?
> perhaps a command to quick delete the separator (|) across all
> the column?
> 
> thx alot in advance
> 
> Z
> 
> 
> 



Re: [O] Complex conversion of text to org table

2017-03-12 Thread Xebar Saram
Thx Vicente!

Thats a decent idea. can this be all wrapped in a function (i have zero
coding skills :)) ? i have hundreds of these tables to convert :)

best!

Z

On Sun, Mar 12, 2017 at 5:26 PM, Vicente Vera  wrote:

> Hello. In this case Org splits into columns everytime it sees a space, so
> "baking soda" ends up in two columns. A brute force solution: replace the
> spaces between words that shouldn't be put into separated columns with an
> underscore:
>
> 1_cup all-purpose_flour
>
> Convert it to an Org table and then do a quick M-x replace-string to
> replace '_' with ' '.
>
> 2017-03-12 15:14 GMT+00:00 Xebar Saram :
>
>> Hi list
>>
>> so im trying to use orgmode to collect food recepies. i have one issue
>> which is to convert text based ingridents list into org tables.
>>
>> for example take this list
>>
>> 3/4 cup milk
>> 2 tablespoons white vinegar
>> 1 cup all-purpose flour
>> 2 tablespoons white sugar
>> 1 teaspoon baking powder
>> 1/2 teaspoon baking soda
>> 1/2 teaspoon salt
>> 1 egg
>> 2 tablespoons butter, melted
>> cooking spray
>>
>> if i mark this as a region and issue 
>> `org-table-create-or-convert-from-region`
>> this is the result
>>
>> | 3/4 | cup | milk| |  || |
>> | |
>> |   2 | tablespoons | white   | vinegar | (%or | better | yet |
>> lemon | juice%) |
>> |   1 | cup | all-purpose | flour   |  || |
>> | |
>> |   2 | tablespoons | white   | sugar   |  || |
>> | |
>> |   1 | teaspoon| baking  | powder  |  || |
>> | |
>> | 1/2 | teaspoon| baking  | soda|  || |
>> | |
>> | 1/2 | teaspoon| salt| |  || |
>> | |
>> |   1 | egg | | |  || |
>> | |
>> |   2 | tablespoons | butter, | melted  |  || |
>> | |
>> | cooking | spray   | | |  || |
>> | |
>>
>>
>> as you can see it got the amount (1/2) and the unit (cup) right yet the
>> actual ingredients is cut into several columns
>>
>> i dont really know how to deal with this. is there a more intelligent
>> way of auto directing the conversion to split it the correct way?
>>
>> if not any suggestions on how to convert it in a better way? perhaps a
>> command to quick delete the separator (|) across all the column?
>>
>> thx alot in advance
>>
>> Z
>>
>
>


Re: [O] Complex conversion of text to org table

2017-03-12 Thread Vicente Vera
Hello. In this case Org splits into columns everytime it sees a space, so
"baking soda" ends up in two columns. A brute force solution: replace the
spaces between words that shouldn't be put into separated columns with an
underscore:

1_cup all-purpose_flour

Convert it to an Org table and then do a quick M-x replace-string to
replace '_' with ' '.

2017-03-12 15:14 GMT+00:00 Xebar Saram :

> Hi list
>
> so im trying to use orgmode to collect food recepies. i have one issue
> which is to convert text based ingridents list into org tables.
>
> for example take this list
>
> 3/4 cup milk
> 2 tablespoons white vinegar
> 1 cup all-purpose flour
> 2 tablespoons white sugar
> 1 teaspoon baking powder
> 1/2 teaspoon baking soda
> 1/2 teaspoon salt
> 1 egg
> 2 tablespoons butter, melted
> cooking spray
>
> if i mark this as a region and issue `org-table-create-or-convert-from-region`
> this is the result
>
> | 3/4 | cup | milk| |  || |
> | |
> |   2 | tablespoons | white   | vinegar | (%or | better | yet |
> lemon | juice%) |
> |   1 | cup | all-purpose | flour   |  || |
> | |
> |   2 | tablespoons | white   | sugar   |  || |
> | |
> |   1 | teaspoon| baking  | powder  |  || |
> | |
> | 1/2 | teaspoon| baking  | soda|  || |
> | |
> | 1/2 | teaspoon| salt| |  || |
> | |
> |   1 | egg | | |  || |
> | |
> |   2 | tablespoons | butter, | melted  |  || |
> | |
> | cooking | spray   | | |  || |
> | |
>
>
> as you can see it got the amount (1/2) and the unit (cup) right yet the
> actual ingredients is cut into several columns
>
> i dont really know how to deal with this. is there a more intelligent way
> of auto directing the conversion to split it the correct way?
>
> if not any suggestions on how to convert it in a better way? perhaps a
> command to quick delete the separator (|) across all the column?
>
> thx alot in advance
>
> Z
>